New research shows that gaining weight during your midlife — between ages 40 and 60 — can increase your risk of getting Alzheimer’s earlier. The study, published in Molecular Psychiatry, was conducted by researchers at the National Institutes of Health (NIH).

Obesity has been linked to cognitive impairment and Alzheimer’s in past studies; researchers have found that obesity increases certain brain proteins, which play a role in developing dementia. In addition, past research has shown that obese people actually have less brain tissue than healthy weight people — their brains shrinking as they get fatter.

“The brains of obese people looked 16 years older than their healthy counterparts while [those of] overweight people looked 8 years older,” Paul Thompson, a neuroscientist at UCLA and an author of the study, said. In other words, obesity accelerates aging much in the same way that smoking, drinking heavily, or living sedentarily do.

It’s no surprise, then, that obesity is linked to Alzheimer’s. But the new study wanted to examine how midlife weight gain in particular could play a role in early development of the disease. They found that being overweight or obese at age 50 could influence the age that one developed Alzheimer’s later on — and it usually meant it would happen earlier.

They examined the Baltimore Longitudinal Study of Aging, a survey that tracks people as they age. The researchers checked some 1,400 participants who had received cognitive tests every year for 14 years — and also tracked their BMI and weight throughout the years. Out of the total, 142 had developed Alzheimer’s — and their BMI predicted how soon dementia would strike. For example, someone with a BMI of 30 at age 50 (which is considered obese, as any BMI over 25 is overweight) could see Alzheimer’s occur a year sooner than someone with a BMI of 28.

“Maintaining a healthy BMI at midlife is likely to have long-lasting protective effects,” Dr. Madhev Thambisetty, an author of the study and a researcher at the NIH’s National Institute on Aging, said, according to the AP. However, the researchers aren’t sure whether staying fit throughout your middle ages will necessarily protect you from Alzheimer’s. More research will be needed in order to solidify this link.

Until then, it’s good to stay on the safer side and take care of yourself – starting sooner versus later. Exercising and eating a good diet has been shown to boost cognitive function and protect your brain, heart, as well as many other aspects of your body. Obesity increases the risk of heart disease, diabetes, cancer, and mental health problems like depression and anxiety, all of which can play off one another and contribute to other chronic diseases.

Source: Chuang Y, An Y, Bilgel M, Wong D, Troncoso J, O’Brien R. Midlife adiposity predicts earlier onset of Alzheimer’s dementia, neuropathology and presymptomatic cerebral amyloid accumulation. Molecular Psychiatry. 2015.