No one would argue that exercise isn’t healthy, but some might argue that pregnant women should avoid exercise. The reality is that exercise during pregnancy can be perfectly healthy for most—as long as a doctor clears it, of course. What’s more, a new study published in the journal Nature Metabolism found that staying active during pregnancy may increase a compound found in breastmilk that lowers a baby’s risk of health issues like diabetes, obesity, and heart disease.

“We’ve done studies in the past that have shown that maternal exercise improves the health of offspring, but in this study, we wanted to begin to answer the question of why,” Kristin Stanford, a lead author of the study, says in a release. “Because there is evidence that breast milk plays a major role, we wanted to isolate the effects of breast milk on offspring health.”

Stanford and her team studied mice to figure out how mothers passed those health benefits down to their offspring. To prove that the traits weren’t just a result of genetics, they fed the babies born from sedentary mothers milk from mouse moms who were active throughout their pregnancies. They found that the fit moms’ health benefits were, in fact, passed down to the sedentary moms’ offspring.

Researchers also used activity trackers to follow around 150 pregnant and postpartum women. They found that women who took more steps per day had more of a compound called 3SL—which may be the source of the babies’ health benefits—in their breastmilk. Since many women can’t breastfeed or need to stay on bedrest during pregnancy, researchers aim to isolate the compound and add it to baby formula.

“The increase in 3SL was not necessarily related to exercise intensity, so even moderate exercise like a daily walk is enough to reap the benefits,” Stanford said. “Exercise is also great for your overall health during and after pregnancy, so anything you can do to get moving is going to benefit both you and your baby.”