Ten years ago, Beth Py-Lieberman learned she had breast cancer. She was fairly certain it was going to kill her. It didn’t matter that her odds of survival were great. She’d watched her mother die from the disease several years earlier, and now the end felt inevitable.

What upset Beth the most was that she was too young. At 46, she was 15 years below the median age of diagnosis in America. She had two kids, a good career. She ate well. She swam. In the past few years, she’d taken up jogging, mostly up and down Sligo Creek Park, a stretch of woods along a creek that meandered by her house in Silver Spring, Maryland.

During chemotherapy, Beth kept running. She’d wait a few days to get over the wooziness from the chemicals pumped into her veins, then force herself out the door, running every two days until her next treatment, three weeks later. To get through a few miles, she’d play a game with herself: Her route in the park took her by four bridges along a creek, so she equated each bridge with one of the four chemo sessions she had to endure. You’ve made it to one, she’d tell herself as she passed the first bridge. Now just get to the next.

Sure enough, the treatment worked. Today, Beth, who was my boss a few years ago at Smithsonian magazine, is as animated as ever—and, surprisingly, still goes for runs by those bridges in Sligo Creek Park. While the route has never stopped reminding her of that awful period of her life, her perspective on feeling so close to death has shifted.

“This is a weird thing to say, but sometimes I’m nostalgic for that period,” she says. “A huge part of maturing for me was saying, ‘Oh my god, I could die soon. I want my kids to remember me as a kind mother. I want my husband to remember me as a kind wife.’ So I became a gentler mother. I became a better wife. I’d never had a transformation like that before in my life.”

All runners know that a familiar trail is a time machine. Like Beth’s bridges, the landmarks along any frequent route become mementos of every variety of experience. A look at the science behind memory suggests runners’ most trodden paths have a secret benefit, too: They not only have the power to transport us back to the past, but help us deal with it when we arrive—even look back on it more fondly. How this happens gets at the very heart of how memories are made.

* * *

Many of running’s psychological benefits already are well-known. It releases dopamine and increases blood flow in the brain, which not only makes people feel better than if they’d stayed on the couch, but helps them think sharper and more creatively, too. In a study published this month in the Journal of Psychology, a group of Finnish and American researchers found that—in lab rats, at least—distance running actually generates more new brain cells in adults than other types of exercise. And earlier studies have shown that running especially increases neurons in mice’s hippocampus, the area of the brain that plays a key role in learning and memory.

So far, experiments that have looked at running’s effects on memory almost exclusively have tested its benefits for retention and voluntary recollection—i.e., concerted efforts to hold onto stuff like where you left the car keys. But what about memories that come to mind that you’ve made no conscious effort to recollect—things you might not have thought of otherwise, maybe even would like to forget? What effect does running have on involuntary memories, like Beth’s associations with the four bridges—and how does it influence what we do with these memories once they show up?

In college, I ran track. A lot of the most triumphant moments in my life came from racing, as well as some of my most depressing failures. In early 2009, my senior year, for instance, my goal was to qualify for a distance relay team at the Division-III National Championships. But I ran a string of slow races and watched that dream go down the toilet.

While training for that relay, I’d sometimes run for miles and think of nothing besides it. I fell into a particularly vivid fantasy one morning on a trail around campus, where my mind played out every step of the perfect race, from the taut silence before the starter’s pistol to hugs and tears on the medal stand. The next day, I caught my mind repeating the same fantasy—on the exact same section of that trail. I’d somehow managed to associate the vision with a pair of two thick wooden fence posts, which seemed to nudge the memory back into my thoughts whenever I passed them.

A reminder of my ambitions was great while I was still chasing them, but horrible after I’d missed my chance. The fence posts brought that imagined glory to mind for months beyond the track season, repeatedly forcing me to think about how I’d fallen short.

According to John Mace, a cognitive psychologist at Eastern Illinois University, involuntary memories like this “tend to come to mind when the mind is wandering, when you’re not focused on a particular task and daydreaming while doing something routine”—something like scrubbing dishes, riding the bus, or, yes, running. (Running itself has yet to be tested for prompting involuntary recollections, as far as Mace knows, but it’s common for people to have them “while they’re driving, especially familiar routes, and what’s going on mentally in running should be very similar,” he says)

The reason the fence posts haunted me is that they acted as “perfect cues”—physical signs that pull a wandering mind back to whatever it was focused on the last time you encountered them. Perfect cues aren’t required for involuntary memories to take place, Mace says—and certainly they aren’t limited to running—but the long stretches that runners cover day after day provide plenty of opportunities for triggers.

To anyone who runs often, this shouldn’t be very surprising. Thinking back on a decade’s worth of routes, I’ve realized whole periods of my life are mapped onto buildings, benches, and trail markers, all of which conjure memories years after they’re made. On Manhattan's Lower East Side, a crop of storefronts makes me think of a podcast I listened to one time as I ran by. Outside of Philadelphia, a park's playground rekindles anger I once tried to run off after a fight with a woman I was dating.

I asked a bunch of runners, from casual joggers to professional racers, if they have similar connections, and their answers included a dip in a road that evokes the movie Red Dawn and a house that brings to mind a Vivaldi Violin concerto. Elkanah Kibet, a Kenyan-born American marathoner, thinks of nursing tendonitis when he runs by a cold river on visits to his home village, where he grew up without ice.

Mace couldn’t offer a definitive explanation for why involuntary memories actually occur, because psychologists haven’t been able to pin them down to any single mental apparatus. But regardless of exact mechanical definition, no one disagrees involuntary memories can pack a special punch. They put the past in front of us whether we want to see it or not. And while that can be vexing—or damaging, in extreme cases like trauma—it’s also the source of a running route’s powers.

* * *

To gain insight into the past, you need what’s called psychological distance. “You want to see [an event] in a different light—in your mind’s eye, if you will, from a third person perspective,” says Kevin Ochsner, a social psychologist at Columbia University.

Why psychological distance is effective has a lot to do with how memories are made. Memory, it turns out, has a dirty secret—it’s an illusion, it doesn’t show us the past as it was, but rather as what we think it should be. “How you feel about a past emotional event now always will color the way you recollect it,” Ochsner says. “If you feel differently about an event now, you’ll misrecollect it to be more consistent with your current feelings than it might have originally been.”

This applies to recollections both voluntary and involuntary. When the brain encodes a memory, it takes in all the sensory elements of an experience and scatters them to different neural regions throughout the cerebral cortex. To retrieve them, it has to reassemble the memory piece by piece. So even though memories seem instantaneous and unified when they appear, our minds actually have remarkable agency in reshaping them.

“There’s no VCR tape that’s an exact record of your life that’s ever stored,” Ochsner says. “[Memory’s] more like working with a document in Microsoft Word without track changes on. You open the document, edit it, and then stored it in the edited form. So when you bring it back to rework it, you don’t have the original anymore.”

This will terrify anyone who wants to cling to the notion that memory infallibly preserves your life’s most precious moments, but the truth is that memory’s built for adaptation, not conservation. It’s a tool for making sense of who and what we are in a big, confusing world. As Ochsner points out, we automatically rely on memories when we have to make snap decisions in new situations, for instance. We appear hardwired to take liberties in assembling memories into clear, usable narratives.

In the month’s following my bad college track season, my feelings about it changed. Running by the fence posts forced me to do the grunt work of sorting through my emotions instead of allowing time to bury them, so I slowly unknotted the tangle of disappointment and shame I carried from not living up to expectations. This was only half-intentional; mostly I’d just bounce my feelings around in the back of my mind for a mile or two, rarely making any conscious effort to clarify them. But I started to appreciate the chance I’d had to invest myself so deeply in something, even though I failed. Success is about process as much as achievement, right? Gradually, the memory turned into a lesson.

* * *

At the risk of sounding like I’m pitching a self-help book, I’d say that running a favorite route turns the wheels of a two-fold therapeutic process—a “physical and emotional context,” in Ochsner’s words, for working stuff out. A familiar route provide cues that encourage involuntary memories; the act of running it relaxes the mind to receive them, and—thanks to dopamine and running’s other cognitive boosters—puts us in the best possible state to deal with them when they come.

Running familiar routes, in other words, conjures our demons and gives us the tools we need to conquer them.  It irons out the past, makes us see ourselves in a more positive light. The process isn’t always quick—it might take some months running by some fence posts, or a decade of passing some bridges—but runners orchestrate it every mile simply by letting their minds wander.

Beth doesn’t remember specifically how she developed a rose-tinted outlook on her illness, but she doesn’t doubt her runs in Sligo Creek Park helped. “I’m sure I was thinking through what the experience meant to me, and making slight adjustments as I processed how I was going to make the best of life,” she says.

She would have thought about her struggle without running, sure. But those four bridges have given her an opportunity to reflect on it in ways she wouldn’t have had without hitting the pavement all these years. She walks in the park more than she jogs in it now, out of a creeping worry about injury as she ages. But she admits it’ll be hard to hold back the pace once the weather gets nice. She misses the rush of a good run—and the clarity it brings. “I’m cleanly open to all sorts of things in the midst of a hard run,” she says. “My body is exhausted. My mind is earnest and sweet.”