Sea turtles use the earth’s magnetic fields to navigate back to the area where they were born decades earlier, according to a new study that used loggerhead genetics to investigate their travels.

After swimming for years in a giant loop from nesting grounds in North Carolina and Florida to North Africa, the turtles find their way back to nest on beaches within about 40 to 50 miles of where they were born. The new study suggests that the turtles learned their home beach’s distinctive magnetic signature, through what is called geomagnetic imprinting.

“This is vital information if you want to restore sea turtles to areas where they once lived before being hunted to extinction,” said Kenneth Lohmann, a professor at the University of North Carolina, Chapel Hill, and senior author of the study published Thursday in Current Biology.

He added that the same concepts may be applicable for restoring salmon and other fish to rivers because many birds and fish also use magnetic fields for navigation.