Scientists and the public alike have long suspected that exercise can reduce depression, but the problem with proving it is the same as with many long-held general associations: it’s just an association. Researchers have shown repeatedly that people who move more tend to have fewer depressive symptoms—but what if people who are less depressed have more motivations to get up and move? Or what if the people who have enough time to stay active tend to have lifestyles less prone to triggering depression?

Questions like these have plagued research on physical activity and depression for years, but now we’re starting to have tools that can help us tease out this complex relationship. One new study, published in JAMA Psychiatry on Wednesday, suggests that there really is a causal relationship: Exercising helps alleviate depression.

To figure this out, researchers working for the Major Depressive Disorder Working Group of the Psychiatric Genomics Consortium used a clever new method called Mendelian randomization, which allows us to understand causal relationships between modifiable behaviors, such as exercise, and health outcomes. The basic idea goes something like this:

It’s hard to know whether exercise influences depression or whether depression influences exercise (or both!) because there are lots of other factors associated with each that could influence the other. People who exercise more might have higher incomes, for instance, and be better able to access therapy and medication. Those with worse depression might be less motivated to move around, or they might have physical pain associated with their depression that makes exercising less appealing. It could even be reverse causation—getting less exercise could make you more prone to depression. These extra associations muddy the picture. But your genes are a lot less prone to these problems. They’re assigned to you before birth in a relatively random way, which mitigates some environmental associations (like having a higher socioeconomic status) as well as eliminating the reverse causation issue.

That means we can use natural genetic variation as an experimental tool. We know that some gene variants make you more likely to exercise, so if physical activity is causing a decrease in depression it follows that people with those variants should be less prone to depression since they’ll tend to exercise more.

Of course, that’s assuming that those genes don’t influence anything else. As an editorial accompanying this study points out, this is an important caveat for all Mendelian randomization studies. “For example,” psychiatrist Adam Chekroud writes, “if the exercise gene variants also relate to low energy, and low energy relates to depression, this relationship would represent another path through which exercise gene variants might affect depression risk.” But he goes on to note that the study authors were aware of this potential misstep and did everything they could to minimize it. Even after removing genes associated with traits like body mass index or education level from the equation, their finding still held.

According to their study, for every one standard deviation increase in physical activity, depressive symptoms reduced by 26 percent. “One standard deviation” is an unhelpful measure of exercise, and though it’s difficult to draw direct parallels the researchers note that it’s approximately equal to one hour of moderate activity like walking, or replacing 15 minutes of sedentary behavior with vigorous exercise like running.

They also decided to measure subjects’ activity level using accelerometers (on top of asking them to report their own activity levels). By looking at how much actual exercise differed from reported exercise, they could figure out whether self-reporting is reliable. And perhaps unsurprisingly, it’s not. The reduction in depressive symptoms—that 26 percent number—only held true for people who actually exercised more.

The study authors themselves note that this is just one piece of evidence supporting a causal role. More research is always going to help strengthen the hypothesis. But in his editorial, Chekroud makes an interesting note: “The reality is that more findings linking exercise and mental health offer diminishing marginal returns. Given that exercise is beneficial, the key clinical question is how we increase the uptake and adherence to exercise and help individuals to measure and monitor their mental health alongside their exercise efforts.”

In other words, we already have a lot of evidence that exercise seems to improve depression (and helps a whole host of other health issues, from obesity to cancer)—enough that researchers suggest we prescribe it as a way to alleviates the symptoms. What we don’t have are many great ways to help people exercise more. Roughly 80 percent of Americans don’t get enough physical activity. That means pretty much everyone could benefit from working out a little more. And as the study authors note, people at risk for developing depression would be doubly helped by getting started on an exercise program early.