A good night’s sleep yields more than beauty—it also means a healthy brain.

According to researchers at the University of California Berkeley, disturbed sleep may contribute to the development of Alzheimer’s disease. The study, performed at the university’s Sleep and Neuroimaging Laboratory, relied on the brain scans of people with both diagnoses. Loss of sleep, they determined, caused a buildup of a “garbage” protein in the brain—one that directly impacts cognition.

The researchers began with a well-studied phenomenon and flipped it on its head. Alzheimer’s, countless studies have shown, causes disturbed sleep, but what if, they asked, disturbed sleep causes Alzheimer’s? “Our findings reveal a new pathway through which Alzheimer’s disease may cause memory decline later in life,” Matthew Walker, senior author of the study and a professor of neuroscience at UC Berkeley, writes.

“It’s the chicken and the egg,” Dr. Owen Carmichael, director of Louisiana State University's Pennington Biomedical Research Center, tells The Daily Beast. “We’ve traced people with Alzheimer’s getting disturbed sleep; this study drills down into the biology of why it’s happening.”

The biology, in this case, comes down to a “stringy” toxic protein that dangles off another one in the brain. Scientists aren’t exactly sure why it’s there, but they do know that it’s dangerous. Luckily, our bodies are aware of this too, and use an enzyme to metabolize the protein until it evaporates.

This process is, more or less, constant. While we’re awake, it’s a slow march. When we fall asleep, it goes into “overdrive.” Those who routinely get a good night of sleep easily get rid of the protein. Those who don’t, leave behind a mess the body doesn’t recognize. Sticky in nature, the protein attracts others that were also left behind, forming a dangerous sheet of (in Carmichael’s words): “gooey garbagey proteins.”

At first, the “gooey garbage” isn’t an issue. But over time the buildup—which can be seen in Alzheimer’s patients up to 20 years before a diagnosis—wreaks havoc.

The concept builds on a study from the same center in October of last year, which examined whether obstructive sleep apnea (OSA) had the potential to cause Alzheimer’s. Published in Neuroscience and Behavioral Reviews, the study relied on sleep brain imaging to examine the overlap in the structure of patients’ brains with the two diagnoses. While a direct link could not be proven, the images showed a “cognitive decline” from OSA, and suggested that perhaps “sleep disturbances” alone may be the issue.

Scientists have zeroed in on the question of general sleep disturbance (not just OSA) before, but have only examined it thoroughly in animals. In one example, Temple University examined using mice with human DNA. Separated into two groups, the mice were exposed to varying amounts of light and darkness, then their brains studied.

Lead author Domenico Praticò found the same result: an abundance of the gooey garbage protein. “This disruption will eventually impair the brain’s ability for learning, forming new memory and other cognitive functions,” said Praticò, adding, “We conclude from this study that chronic sleep disturbance is an environmental risk factor for Alzheimer’s disease.”

A group from the University of Rochester Medical School found a similar toxin-clearing process during sleep to be vital for mice to fully function. “When the mice slept, the cells in their brains literally shrank, making more room for the flow of fluids through the brain,” says the Fisher Center for Alzheimer’s. “This increased flow of fluid acted something like the jet sprays in a dishwasher, flushing away harmful waste products like beta-amyloid.”

Many of the studies on animals end with a phrase suggesting that if the findings were replicated in humans, it could prove vital to finding a cure for Alzheimer’s. “The most interesting part is that disturbed sleep is modifiable and Alzheimer’s is not,” says Carmichael. While he stresses that fixing sleep won’t simply fix Alzheimer’s, he says uncovering the link could be an important tool for the future.

“The data we’ve collected are very suggestive that there’s a causal link,” said Bryce Mander, a UC Berkeley neuroscientist who co-led the study. “If we intervene to improve sleep, perhaps we can break that causal chain.”

Correction 8/28/15 10:30 AM: A previous version of this article wrongly attributed this study to Louisiana State University. It was performed at the University of California Berkeley.