WE spend a third of our lives sleeping, an activity as crucial to our health and wellbeing as eating. But exactly why we need sleep hasn’t always been clear.

We know that sleep makes us feel more energised and improves our mood, but what’s really happening in the brain and body when we’re at rest?

Research has identified a number of reasons that sleep is critical to our health. When we’re sleeping, the brain is anything but inactive. In fact, during sleep, neurons in the brain fire nearly as much as they do during waking hours — so it should come as no surprise that what happens during our resting hours is extremely important to a number brain and cognitive functions.

Here are five incredible things your brain does while you’re asleep — and good reason to get some shut-eye tonight:

Makes decisions

The brain can process information and prepare for actions during sleep, effectively making decisions while unconscious, new research has found.

A recent study published in the journal Current Biology found that the brain processes complex stimuli during sleep, and uses this information to make decisions while awake. The researchers asked participants to categorise spoken words that were separated into different categories — words referring to animals or objects; and real words vs. fake words — and asked to indicate the category of the word they heard by pressing right or left buttons. When the task become automatic, the subjects were asked to continue but also told that they could fall asleep (they were lying in a dark room).

When the subjects were asleep, the researchers began introducing new words from the same categories. Brain monitoring devices showed that even when the subjects were sleeping, their brains continued to prepare the motor function to create right and left responses based on the meaning of the words they heard.

When the participants woke up, however, they had no recollection of the words they heard.

“Not only did they process complex information while being completely asleep, but they did it unconsciously,” researchers Thomas Andrillon and Sid Kouider wrote in the Washington Post. “Our work sheds new light about the brain’s ability to process information while asleep but also while being unconscious.”

Creates and consolidates memories

While you’re asleep, the brain is busy forming new memories, consolidating older ones, and linking more recent with earlier memories, during both REM and non-REM sleep. Lack of rest could have a significant affect the hippocampus, an area of the brain involved in memory creation and consolidation.

For this reason, sleep plays a very important role in learning — it helps us to cement the new information we’re taking in for better later recall.

“We’ve learned that sleep before learning helps prepare your brain for initial formation of memories,” Dr. Matthew Walker, a University of California, Berkeley sleep researcher, tells the National Institutes of Health.

“And then, sleep after learning is essential to help save and cement that new information into the architecture of the brain, meaning that you’re less likely to forget it.”

Think twice before pulling an all-nighter to study for your next exam: If you don’t sleep, your ability to learn new information could drop by up to 40 per cent, Walker estimates.

Makes creative connections

Sleep can be a powerful creativity-booster, as the mind in an unconscious resting state can make surprising new connections that it perhaps wouldn’t have made in a waking state.

A 2007 University of California at Berkeley study found that sleep can foster “remote associates,” or unusual connections, in the brain — which could lead to a major “a-ha” moment upon waking. Upon waking from sleep, people are 33 per cent more likely to make connections between seemingly distantly related ideas.

Clears out toxins

A series of 2013 studies found that an important function of sleep may be to give the brain a chance to do a little housekeeping.

Researchers at the University of Rochester found that during sleep, the brains of mice clear out damaging molecules associated with neurodegeneration. The space between brain cells actually increased while the mice were unconscious, allowing the brain to flush out the toxic molecules that built up during waking hours.

“We need sleep,” Dr. Nedergaard, the study’s lead researcher, told the National Institutes of Health. “It cleans up the brain.”

If we’re not getting enough sleep, our brains don’t have adequate time to clear out toxins, which could potentially have the effect of accelerating neurodegenerative diseases like Parkinson’s and Alzheimer’s.

Learns and remembers how to perform physical tasks.

The brain stores information into long-term memory through something known as sleep spindles, short bursts of brain waves at strong frequencies that occur during REM sleep.

This process can be particularly helpful for storing information related to motor tasks, like driving, swinging a tennis racquet or practising a new dance move, so that these tasks become automatic. What happens during REM sleep is that the brain transfers short-term memories stored in the motor cortex to the temporal lobe, where they become long-term memories.

“Practice during sleep is essential for later performance,” James B. Maas, a sleep scientist at Cornell University, told the American Psychological Association. “If you want to improve your golf game, sleep longer.”

This article originally appeared on The Huffington Post.