Two of life’s great joys—dogs and babies—might be even better together. A study published in the journal Microbiome found higher levels of allergy-preventing bacteria in babies who lived with furry pets like dogs and cats.

The relationship between our environments, immune systems, and gut microbes is a tangled one. Studies have found that “dirty behaviors” like thumb-sucking and nail-biting might actually help protect kids against autoimmune conditions, as can living on a farm. So it’s not too much of a stretch to think that our four-legged companions might have a similarly beneficial effect.

To explore the idea further, researchers at the University of Alberta pulled data from the Canadian Healthy Infant Longitudinal Development (CHILD) study, which followed the lives and health of pregnant Canadian women and their babies.

They found that babies who lived with pets had more of the bacteria Ruminococcus and Oscillospira, which have been linked to lower risk of childhood allergies and obesity. Remarkably, this was true even for households that lost their pets before the baby was born—in other words, pets’ bacterial benefits could even reach into the womb.

Paper author Anita Kozyrskyj noted that the health boost may need to happen early on in order to be effective. “There’s definitely a critical window of time when gut immunity and microbes co-develop,” she said in a statement, “and when disruptions to the process result in changes to gut immunity.”

More research is needed to confirm these findings, as the researchers didn’t examine actual rates of allergies and obesity, only the bacteria that might help prevent them. Still, Kozyrskyj says, the possibility of a future “dog in a pill” is not out of the question. "It's not far-fetched that the pharmaceutical industry will try to create a supplement of these microbiomes, much like was done with probiotics," she said.