We can’t stress the importance of a good night’s sleep enough. Getting a full night of rest leads to plenty of benefits and boosts to your physical, mental, and emotional health. And while everyone has the habits that work best for them, we were curious if anyone had found a scientifically proven “best time” to hit the hay. Well the results are in, and they’re pretty fascinating.

First of all, don’t get your hopes up for a perfect solution. Dr. Matt Walker, the head of the Sleep and Neuroimaging lab at UC Berkeley, tells TIME that there’s no such thing as a perfect “magical” night of sleep. Your sleep quality changes and shifts as the night progresses. But the time you go to bed can also have a significant effect on the structure and restfulness of your sleep.

As we snooze, our brain goes through cycles lasting about 90 minutes each. The cycles move from deep sleep to REM sleep, when your brain is extremely active (this is when you dream). Non-REM sleep is particularly restful, and it tends to occur more prominently in your sleep cycles the earlier you go to bed. As the hours pass, and it gets to be early in the morning, REM sleep becomes more common.

So what’s the final verdict? Well, the later you go to bed, say around 3:00am, the more likely your sleep is to be dominated by REM moments rather than deeper non-REM sleep. That reduction of restorative sleep might make you groggier the next day, even if you get a full eight hours.

Shoot for a bedtime of between 8:00pm and 12:00am to get some quality non-REM ZZzs. But don’t force yourself to jump under the covers the moment the sun goes down. Your genetic makeup, which dictates whether you’re an early riser or a night owl, isn’t something to fight against. Hit the sheets at the time in that window when you feel sleepiest, and let your brain and your pillow do the rest.

Will this data affect your sleeping habits? If you’re ready to shift to early bedtimes because of this article, tell us below!

(Illustration by Peter Oumanski for TIME)