The difference between another failed diet and lifelong weight loss: habits.

After all, while it’s no surprise that humans are creatures of habit, research shows that as much as 45 percent of people’s behaviors happen on repeat each and every day, and often in the same location and around the same time. Your morning coffee? That’s a habit. Binge-watching Netflix to fall asleep each night? That’s a habit, too. For some people, waking up at 5:30 every morning to work out for an hour is a habit.

But the beauty of habits (provided they are healthy ones) isn’t just that you perform them regularly, it’s that you perform them automatically and without thought. That means they hold up even when motivation wanes, according to a scientific review from the University College London’s Health Behaviour Research Centre. Habit formation is why you can drive 30 minutes to work and not actually remember the ride. Your brain – at least the conscious, decision-making part called the prefrontal cortex – doesn’t have to think very hard about the drive or route. Your basal ganglia, which plays a key role in habit formation, has your regular commutes covered. And what was it that you ate for lunch? Exactly.

“Humans like to exist on autopilot,” explains Stephen Graef, a sports psychologist with The Ohio State University Wexner Medical Center. “Doing so expends less mental energy and involves fewer decision-making processes.” Hence why, at the end of a long day at work, it’s easier to sit on the couch and order pizza than it is to hit the gym – that is, unless you set your autopilot to healthy habits.

The 21-Day Myth

So how long does cementing healthy habits (think: following a diet or regularly exercising) take? Likely, quite a bit more than three weeks.

The oft-cited assertion that it takes 21 days to form a habit comes from the 1950s, when plastic surgeon Maxwell Maltz noticed that patients tended to grow accustomed to their surgical outcomes in about 21 days. In that time, he found that a patient might adjust to a nose job or stop feeling phantom sensations after losing a limb. So, when he published the best-selling book “Psycho-Cybernetics” in 1960, he wrote that, “… it requires a minimum of about 21 days for an old mental image to dissolve and a new one to jell.”