Whether it’s trouble falling asleep, waking up in the middle of the night, or tossing and turning so much that you wake up exhausted, we’ve all struggled to catch some z’s. Nutrition and food play a powerful role in helping you sleep and in your sleep quality. Moreover, poor sleep may be an indicator of low levels of certain nutrients. By making a few changes to your diet, you may score some better sleep.

The nutrients in our food are the building blocks used to make neurotransmitters, which are involved in sleep. That’s why certain food can help you sleep and some foods can hinder your sleep. A healthy diet allows your body to absorb these nutrients and provides the brain with the chemical environment it needs to maintain good sleep. If we don’t give our body what it needs to make the natural chemicals that help us sleep, then we wind up with issues. The good news is you can give your body what it needs to sleep soundly and wake up refreshed.

Foods that Sabotage Sleep

Some foods and drinks can really put the kibosh on sleep quality. Try to avoid the following things, especially later in the day, to make sure you sleep as well as possible:

Insufficient Food: Being in a calorie deficit can cause disrupted and shallow sleep. It’s an evolutionary feature to feel more awake and alert when we’re hungry. If our ancestors were starving, falling asleep was not going to ensure survival. They had to get up and hunt or forage for food to make sure they survived. If you aren’t eating enough to support your training, you may have trouble falling asleep, sleep lightly, or wake up hungry. You shouldn’t feel hungry when you go to bed; that’s when your body does most of its recovering, which requires nutrients.

Caffeine: Your desire to sleep is influenced by the build-up of adenosine in the brain. The more adenosine, the sleepier you feel. Caffeine prevents the accumulation of adenosine, which is how it promotes wakefulness and delays fatigue perception. It can also stay in the body for up to six hours (or more), so try to keep it to the morning or early afternoon.

Alcohol: With alcohol, you fall asleep pretty soundly right away, so your body spends more time in deep sleep than it normally would. Then your sleep cycle rebounds and your brain keeps you in lighter sleep stages the rest of the night. As a result, you wake up feeling groggy and less rested. Try to finish any drinks by 7 or 8 p.m. to give your liver enough time to process the alcohol by bedtime.

Highly processed foods: Low-fiber foods, with more saturated fat and more sugar (aka typical junk foods), are all linked to less restorative sleep and cause more awakenings throughout the night. Enjoy a treat every once in a while, but don’t make a nightly date with Ben and Jerry.

Foods that Help Sleep

Fortunately, you don’t just have to play a defensive sleep game. You can also focus on the foods and nutrients that help falling asleep and sleep quality. These nutrients are all ones that can improve your quality of sleep.

Zinc: Zinc plays a role in making melatonin, a hormone that helps regulate our sleep-wake cycle. Our bodies don’t store zinc, so it’s important to get enough in our diet every day. Make sure you’re eating a variety of colorful foods.

Tryptophan: The amino acid blamed for the post-Thanksgiving coma does play a role in sleep (but it’s the carbs that makes you tired after Thanksgiving, not the tryptophan). Your body metabolizes some tryptophan to create niacin (vitamin B3) and pyridoxine (vitamin B6), and converts tryptophan into serotonin and melatonin, both of which are known to influence your sleep-wake cycles. Vitamins B3 and B6 are found in both plant and animal foods, so eating a varied diet helps ensure you get enough of this sleep gem. Calcium also helps boost production of melatonin, so there is some truth to the old adage of warm milk before bed helps you sleep.

Vitamin C: Vitamin C helps lower stress hormones that can be elevated from training. It also helps prevent sleep deprivation. Fruit and tomatoes pack a real vitamin C punch.

Magnesium: Known as nature’s chill pill, magnesium helps increase levels of gamma-aminobutyric acid (GABA), a neurotransmitter that slows down thought processes and nerve activity to promote sleepiness. Exercise can drain magnesium levels, which means athletes benefit from consuming more. Hence getting enough magnesium can improve sleep quality and regulate stress levels.

Iron: Finally, low iron intake has been linked to shorter sleep duration and altered rapid eye movement (REM) sleep. Moreover, low iron levels can cause you to feel tired during the day due to low oxygen delivery to tissues.

Sleep is an important factor in athletic performance—there’s a reason all the pros take naps! And if you can improve your sleep, you may soon find yourself improving your performance and times as well. These nutrition guidelines can help make lights out a whole lot easier and leave you rested and ready for the next day of training.