Ever wonder why you tend to remember your most embarrassing or upsetting moments better than your run-of-the-mill experiences? It might be because of our brains’ preference to reactivate negative emotional memories while we sleep, according to new research presented at Neuroscience 2017.

We know that sleep plays a huge role in memory consolidation (or the way your brain turns new memories into long-term ones), but lead researcher Roy Cox, PhD, a postdoctoral researcher affiliated with Beth Israel Deaconess Medical Center and Harvard Medical School, and his colleagues wanted to look into what sort of memories the brain prioritizes when it comes time to store them.

For their study, the research team wanted to figure out what exactly the brain does during sleep. They had 57 volunteers come into their lab and rate photos based on their emotionality. The photos were either neutral or negative, including “several kinds of unpleasantness,” Cox told me over email. “From pretty intense (wounds, dead human or animal bodies, accidents) to less severe (displays of poverty, aggression, weapons).” Participants looked at the center of the computer screen while neutral images were shown on the right side of the screen or negative images were shown on the left side. The researchers also recorded participants’ brain waves and monitored their sleep. This allowed the them to “tag each [brain] hemisphere,” they write in a summary of the study, according to what type of memory the subjects’ brains were making based on the photo they were viewing (neutral or negative).

Then after either a period of wakefulness or a night of sleeping in the lab, participants took a memory test where they were shown the same images as before— only this time, the images were in the center of the computer screen, and participants were asked to remember which side of the screen the image had been on before.

Subjects in the wakefulness group didn’t remember either of the images well. But people who had slept in the lab before the second memory test selectively remembered the negative images.

As to why our brains seem to prefer negative memories, it might boil down to evolution. Think about this example from Cox: you “discover some nice looking berries and eat them, but then it turns out they’re quite poisonous and you get really sick. In that case, remembering what these berries look like and where you found them could actually help you not to make the same mistake again,” he wrote. “That could be a clear advantage that becomes selected by evolutionary processes.”

Cox explained that it’s unclear if positive memories also get a retention boost during sleep as this study specifically compared negative and neutral ones. But in the next few months, he and his team will start asking questions about how this happens, or if negative memories are already more active leading up to sleep, he explained in his email.

Even though more research needs to be done, these initial findings are important as “there are quite a few clinical conditions that are marked by sleep problems, memory problems or both,” Cox wrote, referencing post-traumatic stress disorder, depression, and schizophrenia, for explains. That’s also true of getting older. And while this research doesn’t address those specific conditions, Cox wrote that “understanding what the healthy sleeping brain is doing will be critical to understand what goes wrong in the diseased or aging brain, and ultimately, how to fix that.”

And while the research is ongoing, it adds more clarity to the link between sleep and memory consolidation. “Understanding what the sleeping brain does to our memories gives us a general sense of the importance and function of sleep,” Cox told me. “With the lack of sufficient sleep in modern society, I think any evidence for the importance of sleep is something that can hopefully help reverse that trend.”