In a case of research backs up things you already know but don’t really want to know, a new study found that work-related stress can lead to unhealthy eating habits after you leave the office. The upside? The study also found that getting a good night’s sleep before a stressful day at work can help you stop reaching for less-than-nutritious foods once the workday is done.

The study, published in the Journal of Applied Psychology, was a collaboration between researchers from Michigan State University, University of Illinois, Auburn University, the University of Florida and Sun Yat-sen University in China.

The researchers looked at two studies that included a total of 235 workers in China. One study involved information-technology employees who reported feeling like they never had enough time in a day to get their work done, according to the study’s press release. The second study looked at call-center workers who often experienced stress as a result of dealing with less-than courteous customers.

In both studies, the researchers found that workday stress created a domino effect: Stress was linked to poor mood and poor mood was linked to unhealthy eating after work. “We found that employees who have a stressful workday tend to bring their negative feelings from the workplace to the dinner table, as manifested in eating more than usual and opting for more junk food instead of healthy food,” co-author Chu-Hsiang Chang, associate professor of psychology at Michigan State University, said in the press release.

Stress eating is not a new phenomenon, of course, and it’s something many people experience. But the findings also back up the power of a good night’s sleep to help offset these impulses: the researchers found that when workers slept well the night before a stressful workday, they tended to eat better after work, Chang said in the press release.

As for why sleep seems to keep stress from spilling over into after-work eating habits, Chang said that a “good night’s sleep can make workers replenished and feel vigorous again, which may make them better able to deal with stress at work the next day and less vulnerable to unhealthy eating,” according to the press release.

The researchers suggest that workplaces take the lead in helping employees balance work stress, nutrition and getting a good night’s sleep. They recommend that companies consider flexible schedules and training staffers on the importance of sleep. Plus, those food-related perks you love in the office often include unhealthy snacks, which might only serve as “temporary mood-altering remedies for stressed employees” Chang said in the press release, adding “failure to address the sources of work stress may have potential long-term detrimental effects on employee health.”

Good sleep is always essential, but if you find that you’re bringing negative emotions home with you from the office—and it’s making you dive headfirst into a bag of cheddar popcorn—it’s even more important that you get your 7-9 hours of rest every night.

Read more about the study here