It’s no surprise that stress sucks for your diet. But even if there’s no end in sight to your mounting work responsibilities, there is one thing you can do to stop the stress from wrecking your waistline: get more sleep, new research from Michigan State University suggests.

In the first experiment, researchers surveyed 125 Chinese information technology employees who regularly experience high workload and feel like they don’t have enough time in the day to get all their stuff done. In the second experiment, they analyzed data from 110 call-center employees who often report feeling stressed by rude customers.

The findings? When the tech employees felt higher job demands that morning, and when the call-center employees felt more mistreated by their customers, they were both more likely to eat more types of unhealthy food and fewer kinds of healthy food later that night.

But when workers slept better the night before, the stress of their workday didn’t affect their eating habits that much—they tended to make healthier food choices when they felt better rested.

The researchers believe that sleep protects against the negative effects of stress, since quality shuteye can make you feel more replenished and vigorous. This makes you better able to deal with stress at work, which leaves you less vulnerable to reach for junk food to make you feel better, they say in a release.

But if you slept poorly the night before and feel the urge to eat everything in sight when your boss piles on yet another assignment, you need to do some recon now: Ask yourself if you’re truly hungry, suggests Susan Schembre, Ph.D., R.D., an assistant professor of behavioral science at MD Anderson Cancer Center.

If the answer is no, try to choose an easily-available and pleasurable activity to engage in instead, she suggests. That might mean taking five minutes to check your favorite meme page, or taking a quick walk outside.