Meet Bailey — a very smart dog who knows exactly where to go when the going gets rough.

Up until recently, Bailey had been living at the Animal Rescue League of El Paso, Texas. There, she won the hearts of staff and volunteers — delighting them with her sweet and loving personality. Finding a family, however, would prove a bit more difficult.

Bailey had the unenviable distinction as the shelter’s longest-serving resident. But a month ago, that all changed.

She finally got adopted — but it wouldn’t be the last time Bailey’s friends at the shelter would see her.

After about a month with her new owner, the unthinkable happened. In a moment of confusion while testing a new harness, Bailey was spooked by something and ran. Her owner just couldn’t keep up.

“She got out of his sight,” Loretta Hyde, founder of the Animal Rescue League, told The Dodo. “He let us know that Bailey was loose, so we asked for people to be on the lookout.”

Bailey had gone missing — but as it just so happens, she wasn’t entirely lost.

Over the following days, reports of Bailey sightings began to trickle in — each one closer and closer to the shelter, about 10 miles from where she’d disappeared.

“For whatever reason, it felt to me that she was on her way here,” Hyde said. “I said, ‘She’s coming back to the shelter.’”

And sure enough, Hyde was right. At around 1:30 in the morning, days after Bailey went missing, staff got an alert from the shelter’s doorbell camera that someone was standing outside.

“[Our staffer] looked and thought, ‘Is that Bailey?’” Hyde said. “You can talk through the doorbell camera, so she hollered, ‘Bailey?’ Then the dog looked at the camera, like, ‘Yeah, it’s me! Let me in!’”

The staffer then drove to the shelter where Bailey stood waiting and did just that.

Bailey had rescued herself.

Along the 10-mile journey, Bailey had to cross many roads to get where she ended up, yet she somehow knew the way.

“She knew exactly where to go,” Hyde said. “Dogs are smarter than we give them credit for.”

Naturally, Bailey was welcomed with open arms by her former caretakers at the shelter. She was hungry and exhausted from her long trek, so they provided her with food, water and a cozy bed in which to rest.

“She ate a big bowl and slept all morning,” Hyde said.

Hyde is quick to note that Bailey adores her new dad and that he is an ideal match for her. In fact, he’d never stopped trying to track her down. But in seeking refuge from being lost, the shelter must have felt still like home.

“That morning, we called him to say we had Bailey,” Hyde said. “He hurried over as soon as he could.”

With that, Bailey is finally back where she belongs, in the loving company of her dad. The whole experience has made one thing clear, however — Bailey still holds a big place in her heart for all the people at the shelter who brought her an him together.

“They’re welcome to come visit anytime. Bailey’s dad appreciates us, and we appreciate him,” Hyde said. “They will be back to visit. I know they will.”