During undesirable situations, such as getting rejected from your dream college or getting laid off from a job, it’s understandable that you may feel disappointed. This sense of failure may give you a greater motivation to push forward, while others will simply give up. But, learning from your mistakes may allow you to be more confident, adaptive, and tolerant to negative situations, according to a new study.

To better understand the relationship between one’s ability to recover from a situation and their self-regulation skills, which include goal-setting and perseverance, researchers studied a group of socially at-risk students. The researchers learned that students who were able to regulate their own behaviors had a much better chance of bouncing back from failure or adversity. They could tolerate problems because they believed they could overcome them.

Read: Follow Your Dreams Without Fear: Oxytocin, Emotional Self-Regulation Turn Threat Into Opportunity

“We wondered whether these students would survive better in the system if they were prepared to overcome adversity,” study author Raquel Artuch-Garde said in a news release. “The research shows the relationship between two essential non-cognitive skills: resilience and self-regulation that are equally or even more important than cognitive aspects in the educational process of students at risk of social exclusion.”

The research, published in Frontiers in Psychology, involved 365 students, aged 15-21 years, from various schools throughout Navarre, Spain. The students’ resilience was assessed using a validated scale that measures a person’s ability to cope with adversity. A separate scale, used for self-regulation, looked for evidence of four factors among each student: goal-setting, perseverance, decision making, and learning from mistakes.

Read: Self-Regulation Skills Better In American Girls Than Boys; Asian Preschoolers Equally Motivated

Arutch-Garde and colleagues found that learning from mistakes was a major predictor of resilience. In their paper, they note their findings show it’s especially important to work on goal-setting and learning from mistakes in socially at-risk children. Both of these principles are deemed to be among the top psychological methods to help students in pre-K through 12th grade learn effectively, according to the American Psychological Association.

“By working on self-regulation skills of students at risk, we encourage their resilient capacity to build an optimistic life plan and to (persevere), which in turn reduces drop-out rates that lead to social exclusion," Arutch-Garde said.

Self-regulation is vital to emotional well-being. You begin developing the skill at a very young age, but there’s always time to grow and improve as you age. Acquiring emotion regulation skills can help with happiness, success, and relationships. One way to build this skill is by setting goals, pursuing them, and persisting even if you feel anxious. Being able to tolerate feeling anxious will allow you to become more likely to try new things even if they failed the first time, according to Psychology Today. Another way to regulate your emotion is to engage in intimate conversations, instead of fleeing them.

See also: Military Kids Are At Greater Risk Of Substance Use, Violence; Promoting Resilience Is Crucial

Resilience Is Uncommon; Just 48% Of People Immediately Bounce Back From Unemployment