Sitting in front of the computer too much is often blamed for America’s obesity epidemic, but finding a balance between screen time and exercise may protect your memory well beyond retirement. Previous studies have already shown that exercise—especially aerobic—is linked to a lower risk of dementia. Scientists think that regular physical activity improves overall health—or is more likely to be done by healthier people—which affects the brain, including memory.

A new study, published in the Mayo Clinic Proceedings, found that combining exercise with mentally stimulating activities is likely to give your memory an even bigger boost. Researchers surveyed almost 1,000 elderly people, aged 70-93, about their physical and mental activities. In this study, researchers focused on the mental benefits of computers because of their widespread use.

Among people who didn’t exercise or use a computer, 37.6 percent showed signs of mild cognitive impairment (MCI), the stage that occurs between normal age-related memory loss and Alzheimer’s disease. However, only 18.3 percent of people who exercised moderately—such as weightlifting or hiking—and used a computer displayed signs of MCI.

Even participants who exercised only once a week showed some memory benefits. The greatest effect, though, was seen with seniors who exercised five or six times a week, as well as used a computer.

The results were greater than what was expected by the researchers, but they weren’t surprised. ”We know physical exercise is independently associated with brain function, and mentally stimulating activities are also independently associated with brain function. Combining the two makes sense,” Dr. Yonas E. Geda, an author on the study, told Time.