Cats seem like they could care less about their adoring owners, flicking their tails as they walk away. But cats and their people go way back. Researchers recently traced their spread around the world to their relations with farmers and travels with merchants and Vikings, Ewen Callaway reports for Nature.

Though the first full dog genome was sequenced in 2005, it took another two years for a cat’s genome to be sequenced. And it wasn’t until 2014 when a high-quality map of this cat’s genes, an Abyssinian named Cinnamon, was finally published.

But in the last couple years, a sharp drop in the cost of DNA analysis is allowing cat-loving researchers to catch up. Recently, an evolutionary geneticist Eva-Maria Geigl, from the Institut Jacques Monod in Paris, presented the first comprehensive study of the spread of felines through history at a conference in Oxford.

Geigl and her colleagues analyzed the mitochondrial DNA of 209 domestic cats found at 30 archeological sites in Europe, Africa and the Middle East. The cats span human history, from the dawn of agriculture through the 18th century.

What the researchers found is that cats spread in two waves. The first explosion happened when agriculture first appeared in the eastern Mediterranean and Turkey, where the wild ancestors of domestic cats live. Geigl suggests that when people began storing grain, they likely attracted rodents. These rodents, in turn, likely attracted the wild cats. Early farmers may have seen the advantages of having cats control the rodent populations and encouraged them to stick around, eventually leading to domestic breeds.

The second wave of cat-spansion happened several thousand years later, explains Callaway. Geigl’s team discovered that cats with a mitochondrial lineage from Egypt began appearing in Bulgaria, Turkey and sub-Saharan Africa between the fourth century B.C. and the fourth century A.D. The team believes sailors may have begun keeping cats on ships around this time to control rodents, spreading them to port cities during trading missions. In fact, a cat with the Egyptian mitochondrial DNA was found in a Viking site in North Germany dating between 700 and 1000 A.D.

The team also looked at the nuclear DNA of some of the specimens determining that the mutation for tabby cats did not occur until the Middle Ages. As researchers continue to look at cat DNA, there will likely be many more revelations.

For decades, researchers believed cats were domesticated in Egypt around 4,000 years ago, writes Stephanie Pappas at LiveScience. But a 9,500-year-old human burial in Cyprus that included cat bones found in 2004 upended that idea, and another study from 2014 indicates that domestic cats were bred in upper Egypt 6,000 years ago. These discoveries, along with Geigl's chronology, show that the history of humans and cats is much longer and more complicated than previously believed.

“There are so many interesting observations,” Pontus Skoglund, a population geneticist at Harvard Medical School tells Callaway. “I didn’t even know there were Viking cats.”