At any given moment, your body hosts a number of different potential pathogens that could infect you, like viruses and bacteria. Your immune system acts like the bouncer at a bar that keeps the riffraff out. Anything that starts replicating too much in a way that could make us sick gets the boot.

But how do these cells know when to react, and to what degree?

Our DNA codes for everything, including the chemicals we need to survive, how much of these substances to produce, and when. University of Utah geneticists have found that some of the code that govern our immune responses come from the genomes of old viral infections from thousands of years ago. Their work was published (paywall) today (March 3) in Science.

The pieces of DNA from these viruses function “as switches for regulating or turning on genes in the innate immune response,” Cédric Feschotte, a geneticist from the University of Utah and lead author of the story, told Quartz.

Feschotte’s team looked at the genes from a specific class of viruses called endogenous retroviruses, a type of virus that reproduces its own genetic material inside our cells, and then take over our cells’ machinery to replicate. When this process occurs in egg or sperm cells, bits of the viral genome get passed down to future generations.

Millions of years later, this virus genetic material actually makes up a substantial part (paywall) of our own—roughly 8%, a fact that Feschotte finds “amazing—and kind of unsettling.”

To investigate the role of this genetic material, researchers examined the gene responsible for triggering cell death at the first sign of infection. In humans this gene, AIM2, produces a protein that detects when a cell has been invaded by a virus or bacterium, and sets off a series of reactions that causes the cell to self-sacrifice to prevent the infection spreading.

They took human cells and used a gene editing technique to delete the sections of DNA from around AIM2 that they knew came from a retrovirus from anywhere between 45 and 60 million years ago. Without this DNA, the expected immune response never happened. The cells kept on living.

This research suggests that our immune system began to use this extra ancient viral DNA for our own benefit. Retrovirus DNA appears in all kinds of other animals, like lemurs, dogs, and mice, and may influence how proteins are produced in different processes, Feschotte said. In this way, past viral infections may be able to stay relevant millions of years down the line.