A good meal can set you up for a good night’s rest, but when you eat also affects how you sleep.

According to sleep expert Peter Polos M.D at mattress company Sleep Number, you’ll want to eat dinner at least three hours before you go to bed. “This allows adequate time for digestion, thereby reducing any possible disruption to sleep caused by poor digestion,” said Polos.

Meanwhile, neuroscientist and sleep expert Sofia Axelrod, Ph.D. says one should at least aim to have dinner around the same time each night.

“If you always eat at the same time, your body learns to prepare the digestive tract to optimally digest the food you eat,” said Axelrod.