Have you ever woken up from a particularly creepy dream and thought to yourself, "Why in the world did I dream that?" I definitely have: My eeriest dream involved a house with invisible fire, and it was not a good time. Everyone dreams, of course, but what exactly is the point of all of that nighttime brain activity? Why do any of us dream at all? Scientists and sleep experts still aren't exactly sure, but a new study may have gotten us one step closer to finding the answer.

The study, published in the journal Social Cognitive and Affective Neuroscience, asked 20 student volunteers, all of whom self-identified as "frequent dream recallers" (i.e. they claimed they were able to remember their dreams pretty often), to keep a journal for 10 days before researchers officially conducted their experiment. In that journal, the participants recorded significant moments from their day, any major activities they did, and anything they were thinking about at the time. They were also asked to record their emotions about these different thoughts and experiences throughout the 10-day period.

After the 10 days passed, the students were then brought into a sleep lab where, according to ScienceAlert, they spent the next several nights so that researchers could observe their behavior and measure their brainwaves while they slept. Additionally, the researchers woke the study participants up at multiple points throughout each night to ask them to describe any dreams they were having in as much detail as possible. Finally, the researchers studied these descriptions and compared them to the 10-day journal entries to see if they could spot any similarities.

Essentially, the researchers found that the purpose of dreaming is to help your brain process experiences — especially emotional experiences — that you have during the day. And while many previous studies have come to similar conclusions, this one is significant in making the connection between memory processing and dreams. Mark Blagrove, a co-author on the study and profess of psychology at Swansea University, told the magazine New Scientist,

This is the first finding that [specific brain] waves are related to dreaming about recent waking life, and the strongest evidence yet that dreaming is related to the processing that the brain is doing of recent memories.

So now that you have a slightly better understanding of why you dream, you might be wondering if it's good for you to dream in general.

According to Dr. Michael Breus, a board-certified sleep specialist and diplomat of the American Board of Sleep Medicine, dreaming can certainly benefit your mental and emotional state. "[Dreams] improve memory, when in REM sleep," he tells Elite Daily over email. "They can certainly help a person process information, as well."

Dreaming can also help make you a better problem-solver. Chris Brantner, a certified sleep science coach at SleepZoo.com, suggests that the dreaming stage of sleep, aka REM sleep, can help your brain come up with ways to best organize the experiences you have IRL. "Through dreaming, deep insights, the ability to solve problems, and strategies for daytime performance are sharpened," Brantner tells Elite Daily over email. "So when you hear someone say 'I'll sleep on it,' well, there's some truth to that. The stage of REM sleep helps you sort and file information, leading to more clarity in decision-making."

Believe it or not, there may even be a positive lesson to be learned from your nightmares, too.

Brantner says that while some nightmares can be traumatic or increase your anxiety, others have a specific purpose: to warn you. "It's theorized that nightmares were useful to survival in older times, as they may have evolved to make us anxious about potential dangers," he tells Elite Daily. "And nightmares about the past may have served as warnings for dangers that could reoccur."

But if you're consistently having nightmares, Brantner suggests taking a look at your sleep hygiene to make sure you're properly preparing yourself for a good night's rest. Eating too late, eating the wrong kinds of foods, being sleep-deprived, and overdoing it on alcohol or marijuana can all keep you from a deep rest, he says.

For now, I just hope that invisible fire doesn't come back to haunt my dreams.