The kicker? Over time, the cycle of efficiently heating up and cooling down may train your body to better adjust its internal thermostat, improving sleep even on days when you don’t work out, he says.

Finally, it’s also possible that the routine of exercise may play a role in shaping your habits and your circadian rhythm, the internal body clock that helps determine when you sleep and wake, Sara E. Benjamin, MD, medical director of the Johns Hopkins Center for Sleep and Wellness, tells SELF. As an early-morning exerciser, she’s experienced this in her own life: “The default for me is to roll out of bed and put on exercise clothes,” she says. “Getting up early to exercise before work means that I need to go to sleep early, so I structure my life as much as possible to allow for this.”

That means she says no to many evening meetings, limits computer time after dinner, and dims the lights in the bedroom as she winds down for the evening. All these steps regulate her circadian rhythms and promote restful slumber. It’s an approach that could work for others, too, she says: “If people make a habit of early morning exercise and that becomes the routine, it may help them to consistently fall asleep earlier than they would without that routine.”

If you have certain sleep disorders, there are even more reasons to try movement.

Some cases of insomnia do have specific causes—many of which seem to respond to physical activity. Take restless legs syndrome, which causes an often uncontrollable urge to move your lower extremities. Symptoms often worsen in the evening and can affect sleep, Dr. Benjamin says.

If you’re in that boat, cardio like walking or cycling may work as an alternative to medication. “People with restless legs tend to do best with a moderate, consistent exercise routine,” she says. “They will tell me that RLS is worse if they don’t exercise at all or when they overdo it one day.”

Another condition that exercise seems to improve is sleep apnea, which occurs when you stop breathing during sleep. Sleep apnea makes your nights less restful and your days drowsier, and can also lead to problems like heart failure, arrhythmias, and type 2 diabetes.

People who followed a 12-week program based on government guidelines for exercise (150 minutes of moderate-intensity cardio a week, plus two days of strength training) lessened their sleep apnea severity by about 25%, according to a clinical trial Dr. Kline and his colleagues published in the journal Sleep in 2011. And in a follow-up published last year, folks who did three weekly high-intensity workouts cut their number of shallow or stopped breaths by an average of nine per hour.

Important note: While doctors often recommend weight loss as a treatment for sleep apnea, these studies showed no change in weight and still found that exercise reduced symptoms. Divorcing exercise from its weight loss implications helped many people in the studies form a more positive relationship with moving their bodies, Dr. Kline says.

There’s no one way to exercise for better sleep.

Right now, docs don’t yet know the exact amount and type of exercise that’s best if you want to sleep like a baby.