About 180 million years ago, whale watching would look a lot different. Instead of giant marine mammals, the oceans were dominated by marine reptiles. Like modern marine mammals, ancient swimming reptiles evolved from land-dwelling ancestors. But a timeline of how they transitioned from land to sea has been difficult to trace.

One group of marine reptiles called thalattosuchians, which are now-extinct, Jurassic-era relatives of modern crocodilians, left behind a detailed fossil record. By studying the changing shapes of their inner ears, an international team of researchers has pinned down the steps that thalattosuchians took to become lifelong seafarers, published yesterday in the Proceedings of the National Academy of Sciences.

“It’s important to look at the sensory systems because those systems are the key to understanding the past, and past animals, and to also understand how animals are going to evolve in the future.” University of Edinburgh paleontologist and lead author Julia Schwab tells Becky Ferreira at the New York Times, “You can tell a lot, looking at the shape of the inner ear, about the environment in which an animal lived.”

Some thalattosuchians—like the largest of the lot, Machimosaurus rex—lived in shallow water habitats like lagoons, Schwab tells Amy Woodyatt at CNN. Machimosaurus rex could grow to over 32 feet long, about twice the size of the average female great white shark, and hunted hard-shelled prey like turtles. The team knew from the creature’s anatomy and the geology around the fossil that Machimosaurus rex was a semi-aquatic reptile—and the thalattosuchians’ inner ears provided further evidence.

The inner ear helps animals keep their balance and sense equilibrium. Land-dwelling animals have relatively slender inner ear labyrinths, with the front canal significantly taller than the back. But whales and dolphins have inner ear structures about a third the size of similarly sized, terrestrial counterparts.

By scanning the inner ears of 18 extinct reptiles and 14 of their modern relatives, the team found that thalattosuchians’ ear canals evolved to become stouter as they moved from shallow habitats further out to sea over time. Based on the findings, it seems like their inner ears adjusted to the high-pressure, deep-sea environment—some may have even been divers. But the inner ears were one of the later parts of their anatomy to evolve.

“The most interesting discovery of this study is that in these marine crocs, the evolution of inner ear features related to a marine lifestyle occurred well after most of the skeleton had adapted to that lifestyle,” vertebrate paleontologist Andrea Cau, who was not involved in the study, tells the New York Times. “For a long part of their history, even the fully marine thalattosuchians kept an inner ear built like their less-aquatic relatives, and this is intriguing.”

For comparison, cetaceans evolved a compact inner ear pretty quickly after they started to live in water full-time. And while both groups reached the same evolutionary strategy, they took different paths to get there.

But one possible explanation for the reptiles’ slower transition is that, while dolphins and whales give birth to live young, reptiles tend to lay eggs. That would require ancient crocodilians like thalattosuchians to stay close to land, where nests could be built.

Speaking to the Times, Schwab suggests that thalottosuchians may have had to evolve live births before they could live for generations in the open ocean. Preliminary evidence shows that the reptiles’ hips widened over time, giving weight to the hypothesis.

“Modern crocodiles lay eggs, and they need to go on land to do that,” Schwab says. “If you’re an animal perfectly adapted for life in the ocean, and have flippers, then it might be difficult to still go on land to lay those eggs.”