Have you ever struggled to learn a new language? It turns out two simple changes to the way you study can make absorbing and remembering new words and grammar much easier. That's according to new research by language learning app Duolingo.

After reviewing the data on tens of thousands of Duolingo users who used the app to learn new languages, comparing when they studied with how well they were performing on the app's tests. That review led them to a simple two-step formula for improving language learning and retention:

1. Study the language right before bedtime.

2. Study every night, weekends included.

To find this out, Duolingo divided its users in 14 groups, based on when they did their studying. The group that studied at bedtime seven nights a week outperformend 52.9 percent of other users, while the worst performing group, which studied at random times, only outperformed 47.9 percent of users. 

"These results suggest a couple of things," write Duolingo research scientist Burr Settles and machine learning engineer Masato Hagiwara in Quartz. "Yes, those who study just before sleeping tend to perform better than other groups. But the time of day isn't the only thing: Equally important is the fact that these language learners consistently studied daily before bed." 

Most of us know that creating a daily habit may be the most powerful way to learn a new skill, or start or stop a habit, or achieve any self-improvement goal. But what does sleep have to do with it? Quite a lot, it turns out. According to researchers at Harvard, learning and remembering consist of three distinct functions: acquisition, consolidation, and recall. You can only perform acquisition and recall when you're awake, but consolidation seems to happen best while we sleep. While our bodies are snoring away, our brains are busily creating the neural connections that form our memories.

Beyond learning a language.

Sleep has cognitive benefits that go beyond helping you learn a new language faster. It's also very beneficial for problem solving, especially when we're faced with a difficult problem, which is why we're sometimes instructed to "sleep on it" when facing a difficult decision. 

I experienced this phenomenon myself when I used to work on challenging cryptic crosswords in bed, right before sleep. I'd often get completely stuck on a difficult word or words, give up, and turn out the light. I often awoke the next morning with the solution fresh in my mind, having somehow figured it out in my sleep. I've tried out the technique on more serious problems too, with good results. And one night, in the days when my husband was a computer repair guy, I found him fiddling with my arm in his sleep in the middle of the night. The next morning he woke up and told me he'd figured out overnight how to complete a particularly troubling repair.

So next time you're trying to learn a new language or solve an intractable problem, take it to bed with you and work on it right before you go to sleep. Your brain will stay on the job while you're getting your well-deserved rest.