If your pants size is inching upward, memory problems may be in your future.

That’s according to a study at the University of California, Davis.

Researchers ran more than 1,300 middle-aged men and women through a series of memory and thinking tests, then had them do the tests again a decade later. People who were obese during the first exam were 39 percent more likely to be in the bottom quarter of mental test scores.

What’s more, people who carried a lot of fat around their middle (a high waist-to-hip ratio) saw their brains physically shrink in size more than slimmer folks or people who carried their fat around their hips, according to MRI scans.

“Loss of brain size causes widespread reductions in thinking abilities, as if your brain was aging more rapidly,” explains study author Charles DeCarli, M.D. The damage could ultimately lead to the development of dementia.

More from MH.co.za: Remember Every Memory

What’s the connection between weight and your brain? Obesity, diabetes, and high blood pressure all cause damage to blood vessels throughout the body, including the ones that feed brain cells, Dr. DeCarli explains. “These changes begin early, so carefully monitoring and treating these risk factors is essential.”

Counteract the effects with exercise. Researchers at the University of Illinois found that people who spent 40 minutes engaging in moderate exercise three times a week for 6 months both increased the size of their hippocampus by 2 percent and also improved their memory. That may not sound like much, but it’s the equivalent of making your brain 2 years younger, according to the study. The key: Keep your heart rate at 60 to 75 percent of your max for 40 minutes—a pace at which you’re breathing harder, but can still hold a conversation.