Let’s be honest: When something goes horribly wrong, the last thing you want to hear is to look for the silver lining.

All sorts of well-meaning people will tell you to "Look on the bright side." But to you, the bright side doesn’t exist. Searching for the silver lining seems about as logical as searching for a button that lets you reverse time and do it all over again.

The suggestion that your pain or frustration can somehow be replaced by optimism seems so missguided, so patronizing, and maybe even downright cruel.

So please forgive me for what I’m about to write: Searching for a silver lining can help you find your way out of a sticky situation—as long as you do it the right way.

It’s human nature to harbor regret, psychologist Jenny Taitz, Psy.D., explained in a recent New York Times article.

“We tend to look back and think that missed opportunities—real or imagined—could have set us on a different, possibly more rewarding path,” Taitz writes. “Left unchecked, these emotions can become overwhelming sources of stress and anxiety.”

It’s human nature to harbor regret.

What can help, she says, is to think about what the experience taught you—aka find our friend the silver lining.

It's as simple as asking yourself: If you were to do it all again, how would you do it? What would you do differently in the future? What did you discover about yourself in the process?

When you do this, you may find that what you’d like to do in the future is different than what you wished you’d done in the past.

“Regret can be a problem, but one benefit of regret is that it signals improvement is possible,” Neal Roese, a professor of marketing at the Kellogg School of Management at Northwestern University, told the Times. “The trick is to avoid obsessing and pull out a lesson that can be applied in future situations.”

You may find that what you’d like to do in the future is different than what you wished you’d done in the past.

Still not convinced? Take a look at the research. One study tested the effects of regret on a sample population. When participants ruminate on their mistakes and losses, they experienced what’s called “ego-depletion,” or a loss of willpower. But when the study subjects were reminded that things can be viewed from a different, positive perspective, and were asked to name one benefit from a regrettable situation, things took a turn: instead of ego-depletion, the participants reported increased vitality, reversing the effects of all that regret.

Think of it this way: If you keep thinking about what went wrong, you’ll continue to suffer. But if you dive deeper into the situation and ID what you’ve learned, you’ll end up feeling better. It’s the same amount of frustration with two different outcomes. Which one would you choose?

Make it easier on yourself by establishing a “silver linings” practice you can turn to when you start to feel those pangs of regrets. Here's how to do it:

Write It Out

Jot down everything you wish you’d done differently.

Maybe it’s a simple as “don’t hit ‘reply all’ when you mean to click ‘reply’.” Perhaps it’s something more like “don’t underestimate how much my experience is worth.”

Whatever the regret, just get it out there. Then, repeat these two phrases from that earlier study:

●︎ Everything can be viewed from a different perspective.

●︎ There is positive value in every experience.

Even if they don’t ring true immediately, try to think of what the positive value might be in your experience. Maybe you’ve learned to pause for five seconds before sending any email. Maybe you’ve learned that standing up for yourself is easier when you have a friend hype you up in advance. Maybe the lesson is just to be a little easier on yourself—that all that hand-wringing doesn’t leave you any better off than before.

Whatever the takeaway, jot that down, too. Then act on it: The next time you find yourself in a similar situation, use what you’ve learned to make a change.

Take A Momentary Break

Need to jolt yourself out of a negative spiral? Taitz has her patients do something that focuses their minds entirely on something else.

One way to do that is by making an alphabetical list of your favorite authors. “When your mind is focused on a project,” she writes, “it’s less likely to get derailed.”

Another option: Pop an ice cube in your mouth. “Focus on the sensations,” she writes. “You’ll find that it’s difficult to simultaneously replay your life’s mistakes while fully participating in doing something else.”

These aren’t permanent solutions, but they may help you break out of a regret spiral and gain some perspective.

Pratice A Little Forgiveness

News flash: You’re not the first one to make a mistake, and you won’t be the last. It’s natural to do or say the wrong thing from time to time. Would you beat your friend up for making the wrong call? Let’s hope not. So extend the same courtesy to yourself.

Maybe that means forgiving yourself out loud: You could try repeating the words “I forgive you” until you feel your shoulders start to relax. Then, once you’re feeling a little more compassionate, have a think on what you’ve learned from the experience.

Silver linings aren't just fluff—the perspective can radically change your mood and next step for the better. Don't be afraid to let them in when things get tough.

Read next: 4 Ways to Coach Yourself Through the Tough Stuff