For people bent on destroying cockroaches, the act of actually squashing them can feel like a game of Whack-a-Mole. The little critters are maddeningly good at running, and once they do get smooshed, they often stand up and scuttle away. Now, writes Elizabeth Pennisi for Science, new research reveals why—and the results could help scientists build better robots.

In a paper published in Proceedings of the National Academy of Sciences, researchers describe just how much weight cockroaches can take before succumbing to force. They put cockroaches through a grueling obstacle course of tunnels that got smaller and smaller, filmed them with a high-speed camera, and even crushed the cockroaches under different weights.

What they found was a surprising combination of agility and flexibility. Cockroaches compressed their bodies between 40 and 60 percent while traversing the tiny corridors, showcasing what researchers call “an unexplored mode of locomotion—‘body-friction legged crawling.’”

Pennisi explains how it works:

The roach first inspects the opening with its antennae. Then it jams its head through, follows with its front legs, and begins pulling the rest of its body into the breach. The back legs splay but continue to push. In about 1 second, it emerges on the far side unscathed.

The team also found that cockroaches’ exoskeletons allowed them to withstand weights up to 300 times their own body weight in small crevices and a whopping 900 times their body weight in other situations. That flexible, strong exoskeleton seems to be the secret to both their invulnerability to squashing and their ability to scuttle off when chased or threatened.

Not content to simply chase and crush cockroaches, the team also designed a soft robot modeled on roaches. It’s not the first cockroach robot, but it could one day save lives. The origami-style robot can swiftly squeeze through cracks—a skill that could help future first responders get a view of unstable or dangerous terrain without endangering humans.

Then again, the ability to navigate tight spaces and scurry away without harm could give surveillance activities or dastardly parties a leg up. Perhaps in the future, the cockroaches you’ll really want to crush will be robotic ones.