If you have trouble sleeping at night, the cause might not be your old pillows or sunken mattress. Instead, a new study says that how well you sleep could be determined by how much purpose you have in life.

Read: 5 Tips On How To Fall Asleep When Nothing Else Works, According To Sleep Experts

Published in Sleep Science and Practice, researchers looked at two longitudinal studies on aging, the Minority Aging Research Study (MARS) and the Rush Memory and Aging Project (MAP). The 825 participants were mostly female (about 77 percent), more than half were African American, and ages ranged between 61 and 100 years old. Subjects who found more meaning and purpose slept better and were less likely to have sleep apnea or restless leg syndrome, according to the report. They also tend to be healthier overall.

For the study, people completed questionnaires about their sleep habits and mailed them back to researchers. To determine how much meaning people found in their lives, each person answered questions such as, “I feel good when I think of what I’ve done in the past and what I hope to do in the future” and “some people wander aimlessly through life, but I am not one of them.” Scores were then averaged and a higher score indicated a higher feeling of life’s purpose.

Study author Dr. Arlener D. Turner told Inverse, “It’s all about having a directive and a focus to what you do in your life and to feeling that your life has meaning and purpose.”

The team followed up with participants for several years, and this study shows that a purposeful life can actually have long-term effects. Researchers believe the findings could be used to develop new treatment options for people with sleeping disorders.

“This could be another avenue for non-pharmacological treatment of sleep disorders” said Turner. “Purpose in life is something that can be enhanced and cultivated. So that can be another avenue, through for example, mindfulness-based treatment.”

And it’s not just your sleeping habits that benefit from a meaningful life. Turner told the publication that people who are satisfied tend to be healthier, overall.

Read: Sleeping Too Much And Not Finishing High School Linked To 600 Percent Increase In Dementia Risk

“What we’re seeing is that individuals who have higher levels of purpose in life also have healthier behaviors,” she said.

“There’s no formal definition of having a purpose in life, but the consensus is that it’s a sense of meaning and feeling that life is worth living,” preventive cardiologist Randy Cohen, MD, medical director of University Medical Practice Associates at Mount Sinai St. Luke’s-Roosevelt Hospital in New York City, told Everyday Health.

According to the Cohen’s research, people with a low sense of purpose had a better chance of suffering from strokes, heart attacks, or coronary artery disease. This could be in part because people with purpose take better care of themselves by going to the doctor and exercising, according to Turner.

Volunteering, finding work you’re passionate about, and pursuing hobbies are all ways to add more purpose to your life.

See Also:

Can't Sleep? 6 Myths About Sleeping You Probably Believe

Sleep And Caffeine Could Help You Naturally Fight Off Chronic Pain​