The iconic caveman in popular culture is Fred Flintstone: slow-witted and unskilled. In general, we think of the cave art produced by prehistoric people as crude and imprecise too—a mere glimmer of the artistic mastery that would blossom millenia later, during the Renaissance and beyond.

If this is your impression of prehistoric humans, a new study published today in PLOS ONE by researchers from Eotvos University in Budapest, Hungary, might surprise you. In analyzing dozens of examples of cave art from places such as Lascaux, the group, led by Gabor Horvath, determined that prehistoric artists were actually better at accurately depicting the way four-legged animals walk than artists from the 19th and 20th centuries.

The researchers evaluated the prehistoric artists on the basis of the landmark 1880s finding by British photographer Eadweard Muybridge that horses (and, it was later discovered, most four-legged animals) move their legs in a particular sequence as they walk. The “foot-fall formula,” as it’s called, goes LH-LF-RH-RF, where H means ‘hind,’ F means ‘fore,’ and L and R mean ‘left’ and ‘right,’ respectively. At the time of Muybridge, this was thought to be an entirely novel discovery.

Except, as it turns out, prehistoric people apparently knew it too—and got it right in their drawings the majority of the time. Of the 39 ancient cave paintings depicting the motion of four-legged animals that were considered in the study, 21 nailed the sequence correctly, a success rate of 53.8%. Due to the number of combinations of how a four-legged animal’s gait can be depicted, the researchers state that mere chance would lead to a 26.7% rate of getting it right. Cavemen artists knew what they were doing.

When the researchers looked at 272 paintings and statues of four-legged animals made during modern times but before Muybridge’s findings in the 1880s, such as a famous horse sketch by Leonardo da Vinci, it turned out that these more recent artists were much worse: They only got the sequence right 16.5% of the time. Remarkably, even the 686 paintings and statues studied that were made more recently than 1887, after scientists knew for sure how four-legged animals walked, still got it right just 42.1% of the time.

Even apart from artists, a sizable number of depictions of four-legged animals made during the 20th century specifically for the sake of accuracy got the sequence wrong too, according to references used in the study. Out of 307 renditions analyzed, just 58.9% of depictions in natural history museums were correct, along with 56.9% of those in taxidermy catalogues, 50% of animal toy models and 36.4% of illustrations in animal anatomy textbooks.

Although the amount of art studied in each group varies greatly, the accuracy rate for animal depictions in prehistoric times is noteworthy. How could prehistoric humans possibly be this skilled at depicting animals such as bulls, antelopes and wild horses? For a potential answer, consider the way these ancient artists probably thought about the animals: as prey.

For prehistoric humans, “the observation of animals was not merely a pastime, but a matter of survival,” the study’s authors write. “Compared to artists of latter eras, when people were not as directly connected to nature, the creators of such cave paintings and carvings observed their subjects better and thus they depicted the walk of the animals in a more life-like manner.”