Stress is just as likely to promote good habits as bad habits, depending on your existing habits, according to research published in Journal of Personality and Social Psychology. Research from the University of Southern California and UCLA found that all types of habitual behavior are reinforced during times of stress.

According to Wendy Wood, professor of psychology and business and study co-author, “When your willpower is low and you have little motivational energy, you are as likely to fall back into old, bad habits of eating too much and not exercising—but only if those are, in fact, your habits. Our novel finding is that people fall back into good habits in just the same way.”

Stress depletes willpower and extreme stress limits activity in the parts of the brain responsible for long-term planning and other higher-order thinking. Decision making is hard when stressed, so people default to habitual behaviors in part because the brain takes on a survivalist mentality.

Wood’s research involved 65 UCLA students who were asked to report about their breakfast and news-reading habits. The students recorded the type of foods they ate for breakfast as well as what kinds of news they read. The research team gathered data for ten weeks, which included stressful periods such as midterms. Once the data collection period was over, the scientists compared how the students breakfasting and news reading habits changed between calm times and stressful ones.

The result was that strong habits were what students returned to during stressful periods. If the students habitually ate healthful breakfast and read the news, they returned to that when they were stressed. Likewise, students who regularly consumed less healthful food or consumed “guilty pleasure” information returned to those habits.

“Our data show that stress and low willpower increased performance of good and bad habits,” commented Wood. Although these outcomes might seem surprising (people usually expect to return to bad habits when stressed), Wood explains that people do not usually realize they are slipping into good habits because good habits are useful, whereas when people return to bad habits, those behaviors stand out more.

These findings could be important for people working to improve their health or accomplish goals. Forming good habits during non-stressful periods will pay off later when life once again becomes stressful.