I signed up for my first half-marathon to impress a boy but ended up impressed with myself. In fact, during the three months it took to train for the race, I picked up an entirely new toolbox of ways to cope with my longtime struggle with anxiety. By the time I crossed the finish line, I couldn’t wait to begin training again. Every time I click the “register” button on another half-marathon, I know that I’m doing something to take care of myself and my mental health.

Running isn’t my cure-all for anxiety—I didn’t ditch my weekly therapy sessions to hit the pavement instead. But it is a tool I discovered during recovery, and signing up for a race holds me accountable to use that tool on a regular basis.

Setting the goal of reaching race day gives me motivation and a clear focus.

Turns out, there’s evidence that proves exercise has a notable impact on brain chemistry—so much so that it may help treat depression and even potentially prevent it from developing. Studies show that strenuous exercise also blocks pain signals in the body and triggers a rush of feel-good chemicals like dopamine and serotonin.

Running helps me get to know my thoughts: I treat my runs as opportunities to begin a new inner dialogue—one that sounds like: You’ve got this. You’re doing a really good job. You’re really strong.

Completing a training run gives me a sense of achievement.

Preparing for a race requires a ton of discipline and organization. In the months leading up to a half-marathon, the whole thing is way less overwhelming when I focus on smaller goals, like my weekly runs. So rather than approach the race as one, large, looming 13.1 mile stretch, I head out the door five days a week and focus on the task at hand (or foot)—finish this mile, sprint to the end of the street, make it up this hill—instead of stressing about the larger end goal.

Sure, I print out a pretty detailed training schedule, but I also make up my own rules as I go. If I need to rest, I rest. Arguably more important than discipline, I’ve learned to have compassion for myself and my anxiety. Some days, rest itself is the achievement.

Concentrating on my breathing is a form of meditation.

Studies show that combining running and meditation can help combat mood disorders, and I’ve found that paying attention to what’s actually going on in my body grounds me in the present moment.

Running has taught me to listen to my body but not panic at the first signs of discomfort. When my heart rate spikes, I slow down. When I feel myself losing control of my breath, I slow down. When my mind begins to race faster than my feet, I slow down.

As Sakyong Mipham teaches in his book Running With the Mind of Meditation: Lessons for Training Body and Mind, “When the mind is totally present, it is relaxed, nimble, and sensitive. It feels lighter and clearer. It notices everything, but it is not distracted by anything. It is the feeling of knowing exactly where you are and what you are doing.”

And it helps me feel like I have a handle on my anxiety.

I’m not suggesting you swap out your antidepressants for a pair of running shoes, although I did wean myself off them under the guidance of a medical professional.

“Anxiety recently passed depression as the most-diagnosed disorder(s) in the US—about 18 percent of Americans have some sort of anxiety disorder, from generalized anxiety to PTSD,” says Elizabeth Wexler, a licensed clinical social worker in Maryland. Wexler recommends physical activity—specifically, doing something active that you genuinely like—to help combat it.

Jennifer Bornemann, an Atlanta-based licensed clinical social worker, agrees. “I absolutely recommend running, biking, swimming, and similar activities as healthy coping mechanisms.” Having completed three Ironmans and countless marathons herself, Bornemann knows firsthand how helpful simply being outside and getting in touch with your breath can be.

In fact, Bornemann suffers from panic disorder and says that having focused on registering for endurance races helped her break through the challenges of feeling not good enough or ‘not strong enough.’ “Physical activity has helped me develop into the me I always knew I could be.”

That being said, listening to everything your body is saying is key. “You need to be in touch with your body and your emotions, as exercise can increase anxiety for some people,” Wexler says. “It’s very individual, and I recommend that people make their priority being aware of and honoring their edge, so as not to trigger more symptoms.”

The icing on the cake? Meeting fellow runners has given me a healthy, supportive social life.

Exercise can also be helpful in breaking through some social anxieties, Bornemann says. “Signing up for races can support goal setting and challenge you to participate in a group activity.”

And although three half-marathons later, the boy I was trying to impress and I broke up, I continued to register for races and spend time training as a way to show up for myself—and form new bonds. Many of my own relationships with other runners have blossomed into deeper friendships. Sure, we started by chatting about our favorite races and preferred cold weather running gear, but those conversations quickly evolved into swapping relationship woes and venting about work stress.

One running buddy, in particular, became one of my biggest supporters. We’ve completed three half-marathons side by side. During the races, we encourage one another, give each other room to breathe, listen in and lean on one another when we need to. It’s pretty much the metaphor for our friendship on and off of the pavement.

Lexi Weber is a freelance writer and longtime runner—she’ll begin training for the National Women’s Half in February. You can follow her on Instagram and read more of her writing on her website.