A new study found that people diagnosed with diabetes have poorer brain power later in life than those with normal blood sugar levels.

The results suggests that keeping the blood sugar levels at bay can lower one's risk of memory problems in the future.

"It gives you an enormous window of opportunity for prevention," co-author Dr. A. Richey Sharrett, of Johns Hopkins Bloomberg School of Public Health in Baltimore, told Reuters Health. "After all, I think people dread dementia more than they dread anything in old age."

Sharrett and his colleagues looked at the data of 13,551 adults who underwent brain evaluation between 1990 and 2013. The average age of the participants was 57, and about 13 percent of them were diagnosed with diabetes.

During the 20-year study period, the researchers saw that those who had diabetes had poorer brain power compared to the healthy participants. The same observation was seen for those who were considered pre-diabetes, or with higher than normal blood sugar but not high enough to be considered diabetic.

The findings contradict an earlier study that found having a healthy blood sugar level does not affect the brain power of the seniors.

"This one says you got a 20-year lead time," Sharrett said. "You can do something about it now, when you're in your 50s - not later."

The researchers clarified that the results of their study do not imply that those with healthy blood sugars are not vulnerable to memory and thinking problems later in life. They weren't sure as well if high blood sugar was the primary cause of poor brain power.

"The study is consistent with other literature we have seen," Heather Snyder, director of medical and scientific operations for the Alzheimer's Association, told Healthday News. Snyder reviewed the study and was not part of it.

Researchers recommend keeping a healthy weight, maintaining a proper diet and exercising regularly to lower one's risk to type 2 diabetes, especially during middle age.

This study was published in the Dec.2 issue of the Annals of Internal Medicine.