If you've ever accidentally stayed up all night long thanks to a new season of Criminal Minds on Netflix, then you know that your brain doesn't do too well without getting its beauty sleep. But what you might not realize is how your bedtime affects your brain on a regular basis, not just on the occasional sleepless night. According to a new study, your nighttime routine can influence your critical thinking and reasoning, and, if you're not getting the shut-eye your body needs, your bedtime might even cause your brain to function as if it's older than it really is. In other words, if you've been slacking on your sleep, it's high time you get that ish in order ASAP.

According to ScienceDaily, the "world's largest sleep study" was recently published in SLEEP — which is the official journal of the Sleep Research Society — and it revealed a whole lot of fascinating details about how your sleep schedule affects your brain health. The study itself lasted for over a year, and included 40,000 participants across the world. The researchers, neuroscientists from Western University's Brain and Mind Institute, studied how the number of hours that you sleep each night affects your brain function. And even when taking into consideration factors that could influence the study's results, like the medications a participant was taking, or their education level, the results were clear: If you want to keep your brain functioning properly, you need to clock in a certain amount of hours of sleep each night — but not too much.

"We really wanted to capture the sleeping habits of people around the entire globe," Adrian Owen, a researcher from Western University and author of the study, said in a statement, as per ScienceDaily. "Obviously, there have been many smaller sleep studies of people in laboratories but we wanted to find out what sleep is like in the real world."

Surprisingly enough, one of the study's major findings was that sleeping either less or more than the recommended seven to eight hours of sleep led to signs of cognitive impairment — in other words, things like reasoning and verbal skills were found to be significantly (and negatively) affected by too little or too much sleep. And get this: Sleeping less than four hours a night, according to the research, was the equivalent of aging your brain almost nine years.

That said, if you're thinking your current sleep schedule could use some improvements, it's never too late to start working on it. Though, according to the National Sleep Foundation, maintaining a healthy sleep schedule does take some adjustment, depending on where you're at right now. If your goal is to go to bed earlier so that you have more time to rest, the foundation suggests that you don't immediately move your bedtime up a few hours. Instead, the National Sleep Foundation explains, teach your body to gradually adjust to this new schedule by shifting your routine in 15-minute increments. For instance, if you usually fall asleep at midnight, start by hitting the pillow at 11:45 p.m. the first night, and then progress from there.

However, Dr. Rita Aouad, a sleep medicine specialist and psychiatrist at The Ohio State University Wexner Medical Center, says you probably shouldn't move your bedtime up too much. "Going to bed too early may disrupt your sleep schedule by causing you to wake up in the middle of the night (sleep fragmentation) or wake up too early the next morning," she tells Elite Daily over email. It might take some trial and error to figure out a bedtime that works for your body and your schedule, but rest assured, it's not an impossible feat.

When it comes to your quest for a healthier sleep schedule, Dr. Aouad says your workout routine could also play a role. "Exercise within your abilities for 20 to 30 minutes daily in the morning or afternoon, but avoid exercise too close to bedtime," she tells Elite Daily. And how exactly does killing it at the gym help you snooze your way through the night? Well, it's not just that exercise tires you out and leaves you feeling kind of sleepy after the fact. According to Johns Hopkins Medicine, getting your heart rate up "increases the amount of slow wave sleep you get," and that's important because, as per the institution, slow wave sleep is the kind of deep slumber that allows your brain to rest and recover from the day.

But if you just can't seem to get your brain to turn off at the end of the day, try writing in a journal or a planner before you finish your bedtime routine, suggests Dr. Aouad. "Don't take your worries to bed," she cautions. "Write down your worries and schedule worry time to address your concerns at a later time." I know that for me personally, making a to-do list for the following day just before bed helps my mind know that it can relax. I fall asleep much more easily knowing that I don't have to worry about forgetting something important.

At the end of the day (get it?), turn off Netflix at a reasonable hour, and try to go to bed at about the same time each night. It will help your brain work well enough that you might just be able to start solving the cases on Law & Order: SVU faster than the detectives can.