Are you that guy at brunch who CAN’T. STOP. playing Candy Crush? Or have you ever reached for another potato chip, only to realize that you had eaten the entire bag in one sitting?

Worst of all, do you acknowledge you have a bad habit — but can’t seem to get rid of it?

“Why we keep doing things that hurt us is a fascinating question, because normally we learn from experience,” said Richard O’Connor, author of “Rewire: Change Your Brain to Break Bad Habits, Overcome Addictions, Conquer Self-Destructive Behavior” (Hudson Street Press). “The automatic, non-thinking brain knows how to drive and type and breathe. That part of the brain really does learn from experience so we don’t repeat the same mistakes twice, except in certain circumstances, like when we’re not paying attention or when we have some hidden motive that’s keeping us in this self-destructive habit.”

In his book, O’Connor draws on the idea that we have “two brains,” a conscious, decision-making one and an automatic one that “quickly gobbles up the potato chip while the conscious self is distracted,” he writes in the book. So in order to kick a bad habit, whether it’s overeating, incessantly playing video games or chronic procrastinating, you have to consciously coach your autopilot self through it, which isn’t always easy.

Remember, degrees of self-destructive behavior vary, as does the time, effort and focus it takes to change that behavior. Here are O’Connor’s tips to getting rid of pesky bad habits:

Practice willpower

“People believe they lack willpower, but willpower is not something you either have or don’t, like blue eyes,” O’Connor writes in his book. It’s a skill, he said, that can be developed with practice by telling yourself no, removing yourself from the temptation or reminding yourself that there’s a bigger reward if you don’t give in. “These kinds of bargains contribute to training the brain so it becomes more easy,” he said.

Try replacement therapy

“The real secret is not to try to break a bad habit but to learn to do something else instead,” O’Connor said. “Our brains are wired to keep biting nails or procrastinating. So we’re used to it. It becomes the default mode. Instead of going on a battle against procrastination, you should reframe it.” However, we can easily go from one bad habit to another, so the trick is to focus on a positive activity you feel good about.

Be realistic when setting goals

“Your standards are very important, and if they’re too high, you can give up before you start,” he said. There are two types of goals you can set:

The overarching goal is where you want to end up, but be aware: “It can be motivational to imagine yourself 30 pounds lighter, but you can also use those kinds of goals to beat yourself up every time you fail,” O’Connor said.

Operational goals, or concrete steps for the next day, week or month, will help you reach the overarching goal. In other words, using weight as the example, focus on losing 2 pounds each week.

Make your goals public

“Talking with other people about how you want to change can be very helpful,” O’Connor said. “They can have experiences or knowledge you can use.” It can also give you motivation when your friends and family help you out by reminding you of your goals.

Don’t sweat the slip-ups

“The good news from all the brain research is (that) every time you practice a good behavior, you’re building up a little network of neurons that make it easier to do the same thing next time,” O’Connor said. “When you slip up, you haven’t hurt yourself too much. You might have a little bit of catching up to do.”