Working out keeps your brain young, suggests a new study from Columbia University and the University of Miami.

Researchers asked people over age 40 about their exercise habits and tested their cognitive abilities. The scientists checked in five years later to test their brains again.

Some mental skills to dwindle around age 30, says study author Clinton Wright, M.D.

But the participants who did moderate-to-intense workouts like running or swimming experienced significantly less cognitive decline over a five-year period than people who were more sedentary. The active participants had better memories and were able to think faster.

In fact, exercising throughout your lifetime may be as good for your brain as turning back the clock 10 years, according to the researchers’ mathematical models.

One possible explanation: Physical activity boosts blood flow to your brain, delivering oxygen and nutrients and removing toxins at a greater rate, says Dr. Wright.

Exercise also fights diabetes, hypertension, and inflammation—conditions that could slowly damage your brain, he says

.