Preparing a nursery for one’s young is a rite of passage for many parents. Humans might fill a corner room with a bassinet, a rocking chair, and a mobile complete with spinning stars. Burying beetles are just as affectionate: They find the carcass of a dead animal, remove its hair or feathers, then smear the body with oral and anal secretions. Only then, scientists write in a new Proceedings of National Academy of Sciences study, are parents ready to bring their babies into the world.

In the study released Monday, a team of Germany-based researchers show how Nicophorus vespilloides, colloquially known as burying beetles, colonize rotting flesh in the name of family. What’s remarkable about these corpse nurseries is that they don’t rot once the beetle eggs are inside them. Normally, a mammal corpse would decompose into a fungal-covered mess, but the team discovered a symbiotic relationship between the beetles and the bacteria in their guts that allows them to craft their creepy cribs.

“Besides being a source of nutrition, the carcass also serves to house the larvae,” lead author Shantanu Shukla, Ph.D. tells Inverse. “The larvae reside and feed within the carcass, consume it and then migrate in the surrounding soil to pupate, once the carrion [flesh of the dead animal] has been consumed.”

Beetle larvae emerges from their "nursery." Shantanu Shukla

This discovery required some truly gnarly experiments. In one, a pair of breeding beetles were given a mouse carcass. When the beetles attended to the body, it resisted degradation and contained low concentrations of the volatile compounds associated with decomposition. A control carcass, meanwhile, rotted away and liquefied, suggesting that the secretions from the beetle mouth and anus does something to the corpses to prevent their decomposition.

Ribosomal RNA sequencing revealed that the beetle-modified corpses had become hosts to bacterial and fungal communities that mirror the gut microbiota of the beetles themselves. A biofilm-like matrix that houses one particular yeast species, Yarrowia, formed around the carcasses as the microbe communities took root. It seemed to play a protective role: When the scientists removed it, they found that fewer larvae were able to survive and grow.

These observations, the scientists write, suggest that tended carcasses host “a mutualistic microbial community that promotes optimal larval development, likely through symbiont-mediated extraintestinal digestion and detoxification of carrion nutrients.” In other words, there’s a coordinated adaptive strategy between the beetles and their microbiome. When they secrete over a dead bird or mouse, the beetle’s gut flora transfers to the carcass and helps it stay fresh and germ-free, creating a safe home for a new generation of beetle offspring. It’s what every young larvae dreams of.

Visually, it’s also not for the faint of heart. If you really want to see what the process looks like, watch this video below and remember it’s no longer a mouse, it’s now a nursery for some babies: