It’s a common suggestion, and it makes complete sense: By doing exercise, you’ll be able to tire yourself out for a good night’s rest. But while it may work for some people, one group of people, insomniacs, will have to exercise consistently for a much longer time to reap the benefits exercise has on sleep, a new study says.

“Where the idea to explore this came from is that my patients were coming in and saying that they heard that exercise that exercise is good for sleep,” Kelly Baron, study author and director of the Behavioral Sleep Medicine Program at Northwestern University, told HealthDay. “But people generally want a quick fix. And they weren’t seeing improvements right away, so they were getting discouraged.”

Read More: Restless Leg Syndrome Insomnia Linked To High Glutamate Levels

Baron’s small study of only 11 sedentary women, all over 57 years old, and who had been diagnosed with insomnia, tested the effects of a four month regimen in which the women recorded their sleep habits in a log, exercised for about 30 minutes three to four times each week, and wore recording devices on their wrist that logged the amount of sleep they got each night, how often they woke up and how long it took them to fall asleep, USA Today reported.

For all the women, it took a while to see the benefits of the exercise. At first, all of them experienced a reverse outcome. Sleeping poorly led to many of them unable to exercise the next day. But after 16 weeks of dedicated aerobic exercising, all women were sleeping an extra 46 minutes each night, which meant that for some, they were getting better sleep with exercise than with sleeping pills, the researchers said.

Read More: Prostate Cancer Risk Doubles With Insomnia And Sleep Problems

“So what this means is that patients need to plan ahead,” Baron told HealthDay. “They need to schedule exercise. Make it premeditated and part of one’s routine, especially on those days when they feel tired or fatigued, or didn’t sleep well, because even if the sleep benefit doesn’t come quickly, with time and commitment it may eventually come.”

Insomnia can be caused by a range of issues, including depression, stress, anxiety, medications, a change in environment or work schedule, and even eating too much late at night. A person with insomnia loses significant amounts of sleep, which can lead to daytime fatigue, an inability to pay attention, and sometimes headaches or gastrointestinal symptoms. Roughly 14 percent of American adults have insomnia.

Read More: Insomnia Affects Brain's Emotion Regulator, Could Lead to Depression

"Patients with insomnia have a heightened level of brain activity and it takes time to re-establish a more normal level that can facilitate sleep," Dr. Phyllis Zee, co-author of the study, said in a statement, according to Fox News. "Rather than medications, which can induce sleep quickly, exercise may be a healthier way to improve sleep because it could address the underlying problem."

Source: Baron K, Reid K, Zee P. Exercise to Improve Sleep in Insomnia: Exploration of the Bidirectional Effects. Journal of Clinical Sleep Medicine. 2013.