It’s easy to get down on yourself when you’re having a rough time with a workout or don’t finish a race as fast as you’d hoped. But the power of positive thinking is real—especially when it comes to athletic performance. Staying optimistic not only ups your motivation, it also makes you less likely to burn out and more likely to appreciate your physical accomplishments, according to research from the University of Murcia in Spain.

Of course, thinking happy thoughts can be easier said than done when you’re huffing and puffing mid-exercise, but recognizing when self-doubt begins to creep in is part of the battle. “When I notice that negative thoughts are becoming my refrain, I work on switching my script a little bit,” says eternal optimist Deena Kastor, who won a bronze medal in the 2004 Olympics and holds the American record in the marathon. “I think, if I’m going to commit to that starting line, then I need to get optimistic on myself.” Read on for her tips on how to do just that and stay positive when the workout gets tough.

1. TEACH YOURSELF.

Thinking positively doesn’t come naturally to you? Don’t worry, it’s not an inherent trait for most people. The good news is, you can learn how to do it. “None of us are born optimists—you have to practice it,” says Kastor. “Practice makes perfect.”

When you notice yourself feeling discouraged, think about shifting your thoughts back to your goal and how you can achieve it or adjust it.

2. TALK YOURSELF UP.

Positive self-talk can help you power through a tough workout or race, but don’t always stick to the same mantra. To stay effective, what you say to yourself should evolve. “Mantras change over time,” says Kastor, who’s repeated phrases like “define yourself,” "believe and achieve," and "find a way" to inspire herself mid-run. “Mantras change their power, so when they cease empowering you, it's time to change them.” For new pump-up words, she suggests drawing inspiration from songs or powerful quotes.

3. KNOW IT'S NOT JUST YOU.

When you can’t reach one of your fitness goals, it can feel you’re the only one struggling with setbacks. “There are a million and one challenges out there; some people have multiple challenges, some are just trying to overcome one,” says Kastor. “But no one ever has a perfect race build-up or perfect training schedule. Life happens and we choose to focus on what’s good or what’s bad.”

4. THINK ABOUT YOUR OPTIONS.

If you’re dealing with a setback like an injury or illness, brainstorm different ways you can deal with it proactively. “You can change a moment of self-pity into a solutions-based mindset,” says Kastor. For instance, “Look at an injury as an opportunity to reassess your health.” You might need to stretch more, work on increasing your strength, or change up your diet.

5. LOOK FOR GROWTH.

Instead of focusing on aches or weakness or that you’re slower than you’d like to be, think about how much you can improve from your current state. “That mindset has made me face challenges with a sense of excitement, rather than facing it with a dread or sense of self-pity,” says Kastor. “It’s an exciting time. What seems like a challenge, which sounds negative, is actually a platform for growth.”