Eating healthy isn’t just good for our waistlines. It turns out, our diet affects sleep in a major way.

While this is still a topic we’re learning more about, a growing amount of research in the last few years has highlighted the connection between what we eat and how we sleep.

I know how enjoyable reaching for that sugary box of cereal in the morning or indulging in a midnight snack can be. But before doing the same, hang on for just a moment. Here are a few key points to consider when it comes to your diet and your sleep.

Your Diet Affects Your Sleep

You can think of food’s relationship to sleep in the same way you think about fuel for your car; sure, you can put the cheapest gas in your tank, but in the long run, it can start to take its toll on your engine.

The same goes for your diet. Putting certain foods in your system might taste good momentarily, but they can end up costing us severely when we’re laying in bed later on.

Research has indicated diets that are high in fiber and reduce both saturated fat and sugar intake make for a good combination when it comes to sleep.

One study found the opposite — low fiber intake, coupled with high saturated fats and sugar foods — was tied to people getting lighter sleep, less restorative sleep, which led to more sleep arousals during the night. This makes competing the 5 sleep cycles more difficult and can lead to fatigue, irritability and headaches the following day.

There are other steps to take — including some that are probably obvious to you already.

For one, avoiding caffeine four hours before bed is important, since coffee and other caffeinated drinks are stimulants. Alcohol has also been thought of as a natural sleep aid for millions, with about 1 in 5 people using it to help them get to sleep. But it turns out it actually does more harm than good when it comes to sleep. Drinking right before bed can help you fall asleep faster, but research indicates alcohol also keeps you in deep, slow-wave sleep longer and gives you less time in REM sleep — the period of the night that helps clear out your mind and help consolidate memories, among other benefits.

Spicy foods can also be a stay-away food before bed, particularly for seniors, because they can lead to heartburn and stomach pain, which will hurt your ability to go to sleep and stay asleep.

The goal is for your diet to foster better sleep. Let’s talk about a few foods that are best for getting a good night’s sleep.

Foods That Promote Good Sleep

We want to focus on the nutrients in our food, because that is what ultimately translates into helping our brain produce the neurotransmitters that are linked to good sleep.

Here are a few options to keep in mind:

Protein-rich foods: Protein is a natural sleep aid that also works to replenish your body during the night. One study found participants who ate meals that were high in protein and low in saturated fats fell asleep much faster than those who didn’t, with an average of 17 minutes to fall asleep, compared to 29 minutes for the others. Foods that help here include: Eggs, fish, chicken breast, broccoli, quinoa, and almonds.

Fiber: As mentioned above, fiber has been linked to deeper, more restorative rest. People with a high fiber intake have been associated with spending more in REM sleep, the sleep cycle best associated with dreams, according to a study from Columbia University. Avocadoes, pears, chickpeas, lentils, oats and dark chocolate all boast high fiber percentages.

Potassium: One of the more important minerals. Potassium promotes healthy circulation and digestion, while also helping to relax muscles — which all contribute to better sleep. Bananas are best known for potassium, but fish, mushrooms and several different beans are other positive sources.

Magnesium: I’ve talked about how important magnesium is when it comes to sleep extensively in the past. Magnesium maintains healthy levels of GABA, a neurotransmitter that promotes sleep. Studies have also shown deficient magnesium levels are linked to insomnia. Since magnesium isn’t produced inside the body, it’s critical we add foods to our diet that provide it. Some foods we’ve already mentioned are good sources of magnesium, including bananas, spinach, and avocados. Other options include brown rice, tofu and cashews.

By avoiding excessive amounts of sugar, while aiming to keep these nutrients prominently featured in our diets, we can give ourselves a better chance of getting a good night’s sleep.

Sleep Can Affect Your Diet, Too

Sleep and diet act as a two-way street; what you eat impacts your sleep, but how you sleep also affects your diet.

A new study that just came out this week drove this point home. Researchers found out of 500 women between the ages of 20-76, those who were sleep deprived ended up having worse eating habits, including eating more foods that were high in sugar and saturated fats. They were also more likely to drink excessive amounts of caffeine.

The study found 30% of the women slept less than 7 hours each night. Those women tended to eat between 500-800 more calories per day than well rested participants, and they were also found to be falling short of mixing in healthy foods, like grains and fiber, in their diet.

The researchers hypothesized that because many people work late into the night, they are sleep deprived and more likely to make short-term food choices that are quick and easy, but do not carry nutritional value. This, in turn, hurts their sleep quality and it becomes a problem that feeds itself.

Benefits of Quality Sleep

Before wrapping up, it’s important to remember why this matters. Sure, eating healthier foods can help you get longer, better sleep, but does that really make much of a difference in your day-to-day life? The answer is unequivocally “yes.”

There are a number of benefits that come with completing the 5 sleep cycles, including:

  • Reduced stress
  • Improved energy levels
  • Lower blood pressure
  • Better mood
  • Less headaches

It also reduces the risk of suffering from life-altering diseases like diabetes.

A good diet is an essential part of getting quality sleep. Pairing smart food choices with a healthy sleep schedule and hospitable sleep environment is the three-pronged attack we need for great rest.

This post originally appeared on The Sleep Doctor. It is republished with permission.