We all have them — bad habits that we wish we didn’t have but feel pessimistic about changing. Maybe you know you really have to spend less time on Facebook or playing online games. Or perhaps you’ve tried a dozen times to quit smoking. Or maybe even thinking about getting more exercise makes you feel too tired to start. Whatever habit you’re trying to break, somehow you haven’t found the key to success.

Search no more. Bad habits can be broken. Really. Here are 7 tips from the researchers who research such things:

1. Cut yourself some slack. Habits are hard to change because, well, they’re habits. There’s a reason why they are hard to break. We actually need most of the habits we have. We go through most of our days engaging in good habits, routines and activities. If we didn’t, everything we did every day would be something we’d have to think about. Instead, we’re wired to learn and put in place activities that sustain us without giving it a moment’s thought.

From the time you stumble into the bathroom in the morning to wash your face to your drive to work where you have a “habit” of following traffic rules, to your routines as you go through your workday to kicking off your shoes when you get back to the house, you are on autopilot a fair amount of the time. That frees your mind and your energy for new situations and new problems that require new decisions, creativity and actions. Unfortunately, the brain really doesn’t discriminate between the bad habits and the good ones. Once a routine is sorted into the “automatic” category, it’s hard to get it back out.

2. Identify the underlying cause. All habits have a function. The habit of brushing your teeth every morning prevents trips to the dentist. The habit of checking your email first thing at work helps you organize your day. Bad habits are no different. They too have a function.

Mindless eating can be a way to comfort yourself when you’re feeling down. Cruising the Internet for hours might be a way you avoid interacting with your partner or kids. Smoking (in addition to being just plain addictive) may be a way to take time out to pause and think. Drinking too much may be the only way you know how to be social. If you want to break the habit, you have to come to grips with whatever function the bad habit is serving.

3. Deal with the real problem. Sometimes dealing is relatively easy. If snacking on junk food all afternoon is a compensation for not eating lunch, it’s obvious that the function of eating whatever is in the vending machine is to satisfy hunger. Your “habit” is telling you that you really do need to stop and take the 15 minutes to have lunch. But if your time on video games is your way to stay out of fights with your partner, it may be painful to face how dysfunctional your relationship has in fact become.

Even if it makes you feel guilty and bad about yourself for having a bad habit, you are not likely to stop it unless you come up with another way to deal with its function. Something positive has to be put in its place. Positive can mean pleasant — like eating that lunch instead of skipping it to forage in the vending machine later. Positive can also be painful but important — like dealing with your feelings instead of stuffing them down with food, or getting into therapy with your partner instead of numbing your problems away with video games or alcohol or weed.