Stimulating the brain while young, through leadership roles at work and other opportunities, may help people stay mentally healthy when they’re older, according to new research.

Researchers at the University of Exeter studied how experiences in early or mid life challenge the brain to make it more resistant to the changes that come along with aging or illness. This is known as “cognitive reserve.”

Read: Drinking Beetroot Juice Before A Workout May Help Aging Brain Look ‘Younger,’ Study Finds

The data, which included more than 2,300 mentally fit people over 65 years old, indicated people with higher levels of reserves have a better chance to stay mentally fit into later life, making the brain more resilient to changes.

Prior research has indicated people with a greater cognitive reserve are less likely to exhibit common signs of dementia, such as memory loss.

“Losing mental ability is not inevitable in later life,” said study author Linda Clare, in a press release on ScienceDaily. “We know that we can all take action to increase our chances of maintaining our own mental health, through healthy living and engaging in stimulating activities.”

All of the study participants took a mental ability test. The researchers concluded that a healthy diet, moderate alcohol consumption, higher levels of exercise, and more social and mental fitness activities were associated with better scores on the cognitive test. These factors also help avoid heart disease, study author Fiona Matthews noted.

This research is the first part of a trial among older adults that seeks to find the lifestyle measures that can make a meaningful difference to keep people physically and mentally active as they age.

See also: Mindfulness Training Benefits: Results For Older Adults Are Mixed, Study Says

Health Benefits Of High-Intensity Exercise: HIIT Fights The Aging Process In Older Adults, Study Finds