We’ve all heard plenty about exploding batteries this year, so it’s kind of funny that scientists are just now digging into what actually causes rechargeable power sources to go nuclear. A new paper published in the Journal of The Electromechanical Society details how researchers used an X-ray to track the changes happening inside a battery as it reaches its ultimate breaking point.

IPHONE 7S NEWS: Insider report details changes coming to next year’s iPhone 7s and 7s Plus

To test exactly why a perfectly normal, functional battery would suddenly have a catastrophic meltdown, the scientists put a store-bought battery through a torture test. The researcher’s gauntlet included charging, discharging, and overcharging the battery, and X-raying it after every step.

The resulting images were able to shed some light on the process that creates the telltale “pillow” effect on a failed batter, and what often leads to an explosion or fire. In the image above, the top scan is from the healthy battery, while the middle image is the same battery after undergoing testing. You can clearly see the large air pockets that have formed between its layers, especially in spots where the layering was already poor.

When the liquid inside a battery turns to gas — often when the battery is overheated or charged past its limits, or left completely depleted for an extended period of time — the battery can begin to swell up. A swollen battery may be completely dead, but sometimes if the pillowing isn’t severe, it can still provide power. Using it, and especially overheating or straining the battery in any way, can cause more serious problems.

Whether this rapid expansion results in an explosion is the product of many factors, such as the battery’s housing and materials used in its casing. Oftentimes batteries simply turn into little blimps, while others violently split open, causing all manner of destruction.