It’s time to shed some light on this mystery.

Fireflies on summer nights are one of the great things about growing up in America — but you probably don’t know how they make that soft yellow light.

That question has baffled scientists for decades. Back in the day, entomologists (aka bug scientists) knew that the light came from a chemical reaction inside the firefly but weren’t sure exactly how it happened.

According to Scientific American and National Geographic, fireflies have what’s known as a “light organ” in their abdomen that contains calcium, adenosine triphosphate (ATP), magnesium, luciferin and luciferase. Those last two chemicals are particularly important: luciferin is what actually creates the light while luciferase is an enzyme that speeds up the chemical reaction.

All of these chemicals lay dormant inside the light organ until the insect decides to spark up — which scientists call bioluminescence. When it does, it “breaths” oxygen in through its exoskeleton (bugs don’t have lungs like humans do).

Getty Images/shaunl

Once the oxygen is inside the firefly, it’s greeted by mitochondria. Remember your high school biology teacher telling you over and over that mitochondria is “the powerhouse of the cell?” Congrats — that information is finally relevant.

See, mitochondria produce ATP. ATP is a molecule that stores and uses energy — think of it like a battery. The energy it stores gets used for a whole bunch of important bodily functions, but in fireflies’ case it provides the energy necessary for bioluminescence, which fireflies use both to attract sexual partners and to deter predators. (Talk about killing two birds with one stone, amiright?)

The mitochondria in fireflies also act as a buffer to separate the oxygen in their light organ from the other chemicals that are present there. According to a study published by the National Center for Biotechnology Information, oxygen is introduced to the other chemicals through the presence of nitric oxide gas. This compound allows oxygen to flow through the mitochondria into the light organ. Once all the chemicals are present, a reaction takes place that produces what scientists refer to as “cold light.” This is light created without giving off any heat; it basically allows the little guy to light up without bursting into flames.

Getty Images/ kororokerokero

Still, there’s one problem that confused scientists for nearly 60 years — oxygen doesn’t actually react with the chemicals in a firefly in a way that produces light.

Thankfully, a team of biochemists from Yale, Connecticut College and the University of Buffalo decided to figure this issue out. Their research — published back in the summer of 2015 — found that the firefly’s special power comes from something called superoxide anion. This “oxygen intermediate,” as Yale’s website calls it, has an extra electron that lets it act as a mediator between oxygen and the light-giving luciferin.

Beyond summer-evening fun, this chemical reaction also has practical applications: scientists have used fireflies to make breakthroughs in efficient LED lights and cancer research.