Animal migration is one of the most charismatic, awe-inspiring phenomena of the natural world. Faced with unfavorable, often seasonal, changes in climate or habitat quality, animals, from birds to butterflies and wildebeests to sea turtles, migrate vast distances—often thousands of miles—in search of more favorable conditions. They return the following year, in many cases to the exact location where their journey began.

How do animals know where and how to migrate? Their migratory means are not exactly easy to study. Technological advances such as satellite tagging have revealed many secrets of migration routes and destinations. However, the great distances these animals travel and the difficulty of observing them leaves scientists in the dark about many of the basic behaviors of migration. Plus, getting your hands on a migrating animal is no easy feat; one does not simply sneak alongside a heard of migrating caribou or snorkel with migrating salmon undetected.

We know that some species use the Earth’s magnetic field to navigate with GPS-like precision and others gaze skyward and guide their migration by the stars. We are just now learning that for some animals, the key to a successful migration is all in their heads—complex thought and memory are also necessary for a successful migration.

For nearly a decade, we have studied the roles of cognition, learning and memory in the migration of a fairly atypical species—the painted turtle, common to neighborhood ponds and roadside ditches. Yep, that turtle—the one you see in virtually every small body of water in the Eastern U.S., as well as occasionally crawling through your backyard or crossing the road by the grocery.

They’re not as charismatic as sea turtles, and they sure don’t travel as far (several kilometers for a painted turtle versus several thousand kilometers for a sea turtle), but what they lack in outward charisma they make up in tenacity. When these turtles take to land each summer, migrating to new habitats when their home ponds dry up, they face seemingly insurmountable odds: scorching heat, dehydration, and the crushing tug of gravity (you can’t just float around anymore). And that’s not to mention the new predatory threats from both land and air, and the ever-present threat of vehicles when crossing a road. For a painted turtle, there’s a lot going on during migration.

Painted turtles at our research site, which is on conservation land within a patchwork of old growth woodlands and agricultural fields, follow long, intricate routes with amazing precision—specific to within a few meters—to far-off, permanent water sources year after year, returning home again when the seasons next change. Is this behavior instinctual or learned?

To see just where this incredible migratory behavior came from, we introduced into our site animals without any experience migrating there and monitored their ability to respond to seasonal changes in their habitats. Would they be able to migrate successfully?

For some, yes. Naive juveniles under four years old learned to navigate the complex paths just as precisely as experienced local turtles and were able to locate far-off water sources. Naive adults could not. These results suggest a narrow age window, or critical learning period, in which animals must learn to navigate. This phenomenon is not unlike the process of language learning in humans.

But how can they do this? How can a turtle possibly think its way through migration?

They do it the same way that we do: they form and remember memories of space and place using the neurotransmitter acetylcholine, just like humans. Acetylcholine has long been known to play a role in spatial memory in mammals. To test whether the turtle brain also works this way, we gave freely migrating turtles (both experienced adults and naive juveniles) mind-altering drugs that temporarily block acetylcholine in their brains.

While the drugs were active and the turtles were without access to spatial memory, the adults with previous experience in the system wandered aimlessly and were unable to follow their traditional migration routes. As soon as the drugs wore off, they got right back on track and were able to successfully migrate to their winter home. And what about naive juvenile turtles? They were unaffected by the drug; they followed the paths perfectly whether on the drug or not. Why? They had no memory to disrupt! This demonstrates that adults use spatial memory to navigate during migration, and that they form these memories as juveniles prior to the age of four. This type of higher-order cognitive processing during migration has been previously attributed only to birds and mammals.

So, it turns out that if you’re a turtle, migration is more than just showing up and muddling through on instinct; you actually have to pay attention and think. And for the turtles, that’s a good thing.

Challenging environments—those with the most extreme, highly variable conditions—tend to produce animals with advanced cognitive abilities, including flexibility in learning and memory.

As climate change continues to disrupt environments, animals will have to rely on cognition to learn new things, including altering the timing, direction and destination of their migrations.

So even though the odds are stacked against them, maybe, just maybe, turtles can outsmart the impacts of climate change.