It’s no secret that a good night’s sleep can do wonders for your mood. Now, a new study shows that improving your Z’s over time is associated with better health and well being. In fact, researchers say, scoring better shuteye perks up mental health as well as winning the lottery.

The findings come from analysis of more than 30,500 British people who were followed for about four years. University of Warwick researchers found that people who reported improved quality of sleep over that time period, or who reduced the amount of sleep medications they took over that time, tended to also improve their scores on screening tests for physical and emotional health.

Overall, their mental health improvements over the four years were comparable to those seen in British lottery winners two years after hitting a medium-size jackpot worth about $250,000. So, to be clear, we’re talking about a long-term mood boost—not the immediate euphoria of striking it rich.

Unsurprisingly, people whose sleep patterns got worse over the study period were more likely to see their physical and emotional health scores go down.

Cathy Goldstein, MD, assistant professor of neurology in the University of Michigan Sleep Disorders Center, says that the study results confirm what’s long been understood in the medical community: that good-quality sleep can improve mood.

“When we sleep well, we feel better—but there may also be more than that,” says Dr. Goldstein, who was not involved in the new study. “If you’re irritable and having difficulty with interpersonal relationships, that could affect your well being. We also see changes in inflammatory markers with poor sleep, so people might actually physically feel worse when they’re not sleeping well.”

Studies have also shown that poor sleep can slow metabolism and lead to weight gain, she adds, which can also affect both physical and emotional health.

Health.com: 8 Natural Remedies That May Help You Sleep

The study, which was published in the journal Sleep, can’t prove a cause-and-effect relationship between sleep and better health outcomes, and Dr. Goldstein says that the two are quite intertwined. “If people were feeling better at the end of the study, that certainly could have been what resulted in them having better sleep up to that point,” she says. “It’s a bi-directional relationship, for sure.”

The study also found that when people’s sleep duration improved, their mental health scores did too—but their physical health scores didn’t. The benefits of longer sleep on physical health may take longer to emerge, the study authors speculate, or they may only be evident in people who are significantly sleep deprived.

Sleep quality, on the other hand, was linked to both physical and mental health. This finding “challenges the predominant focus on sleep quantity in some of the public health messages,” say the authors, who argue that how well you sleep is at least as important as how much you sleep.

Health.com: The 11 Kinds of Insomnia

There’s no question that many of us could benefit from better sleep practices, says Dr. Goldstein. “Most people need seven to nine hours, and humans don’t sleep with 100% sleep efficiency,” she says. “So if you turn off the lights at 10 and wake up at 5, that’s probably not a full seven hours of sleep.”

She recommends spending at least seven and a half hours in bed, and paying close attention to how you feel during the day. “If you’re still feeling tired, it’s possible you could have a sleep disorder, like obstructive sleep apnea, that’s keeping you from getting good quality rest.”

The study authors say that an important next step in this research is finding out why some participants’ sleep improved over those four years and why other’s declined, and what lifestyle factors seemed to play a role, for better or worse.

For anyone looking to improve their sleep quality, Dr. Goldstein says a good place to start is keeping electronic devices out of the bedroom, and reducing exposure to screens and bright light between dusk and bedtime. “Our bodies were not equipped to get that bright light, and it’s going to suppress melatonin and make it harder to sleep,” she says.

She also recommends talking to your doctor if you have trouble falling asleep, staying asleep, or if you regularly feel tired during the day—even if you’re technically logging the “right” number of hours in bed.

This article originally appeared on Health.com

Get our Health Newsletter. Sign up to receive the latest health and science news, plus answers to wellness questions and expert tips. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Contact us at letters@time.com.