A team of chemists just solved the mystery of why comets’ heads–but not their tails–glow green, which had puzzled researchers for decades. Studying an elusive molecule, which only fleetingly exists on Earth, was the key.

Comets are speeding chunks of ice and dust left over from the formation of the solar system, which occasionally venture from the system’s cold outer reaches to pass by Earth. Back in the 1930s, Gerhard Herzberg, who later won the Nobel prize for his research on free radicals and other molecules, guessed that the process behind the green comet glow might involve a molecule made from two carbon atoms bonded together, called dicarbon. A new study, published in the journal the Proceedings of the National Academy of Sciences, put Herzberg’s theory to the test.

Dicarbon is so reactive that the team behind the study couldn’t get their supply of it from a bottle, says Tim Schmidt, a chemist who oversaw the study at the University of New South Wales in Sydney, Australia. In space, it exists inside stars, nebulae, and comets. But when exposed to the oxygen in Earth’s atmosphere, dicarbon will quickly react and “burn up,” Schmidt says. 

Schmidt says this is the first time scientists have been able to examine precisely how the molecule breaks apart when exposed to powerful ultraviolet rays. In the lab, the team had to simulate the environment of near-Earth space with vacuum chambers and three different ultraviolet lasers. Because dicarbon reacts so quickly, they had to synthesize it on the spot by whittling away a larger molecule with a laser.

They confirmed comets’ green light comes from the dicarbon molecules, which, when exposed to sunlight in space, can absorb and emit visible light, Schmidt says. Herzberg was right about dicarbon, he says, if not quite correct about the mechanism–but it was the 1930s, Schmidt says, so “he can be forgiven.”

[Related: How to tell an asteroid from a comet, even when its from outside our solar system]

In comets, dicarbon forms when sunlight heats up the ice, some of which is probably made of acetylene, a mixture of hydrogen and carbon that, as a gas, is used on Earth for welding fuel. It could be produced in space when more complex organic molecules in comets break down, Schmidt says. 

The hydrogen atoms break free from the acetylene molecules and without them, the bonds between the carbon atoms “tighten back up again,” forming double carbon molecules, Cochran says.

As the sun heats the molecules in the comet’s body, they gain energy and glow, but they break down into single carbon atoms before they can reach too far into its tail. This explains why the green glow only exists around the body of the comet, not its long tail. 

While the comets are exposed to enough sun to release gas, the sun’s rays are constantly creating new glowing dicarbon. The lifespan of dicarbon molecules at the Earth’s distance from the sun is about two days, according to Schmidt. 

The team was able to learn how dicarbon splits in the lab and show that scientists “were right” to think they’d witnessed dicarbon’s glow in real-world comets, says Anita Cochran an astronomer and assistant director of McDonald Observatory at the University of Texas at Austin who was not involved with this research. “They’ve determined it rigorously now,” she says.

Cochran, who has spent most of her career looking at comets, says that they can make great laboratories because telescopes can get a good look through their enormous tails, often millions of miles long to figure out what they’re made of.

The team learned the lifetime of the dicarbon molecules exposed to sunlight and measured how much it takes to break apart their bonds, Cochran says. These facts will help with modeling comets’ behavior. A passing comet might seem like a rare event on Earth, but astronomers now have spotted thousands of them. Incredible numbers of comets probably exist in the further reaches of the solar system. Thanks to these green-glowing snowballs, scientists have a window into the ancient past of the solar system.