It’s the middle of the night, and you and your bed-partner are wide-awake running your hands over each other’s bodies. No, it’s not what it sounds like. You’ve got bedbugs.

Bedbugs have recently reinvaded American cities like New York, hiding in the tiny folds of mattresses and even cracks in walls, causing itching, redness and ultimately insomnia. Now scientists, publishing a new paper in the Journal of Medical Entomology, have done some intricate genetic detective work to find out how the critters have evolved a strong resistance to the insecticides used against them.

Looking to reveal the evolution behind the bugs resistance to chemical insecticides called pyrethroids, the researchers compared a population of Floridian bedbugs maintained pristinely without pyrethroid exposure from their capture 20 years ago with a group of modern New York bedbugs resistant to the poisons. They discovered that the New Yorkers had a mutation that shores up their nerve cells against the effect of pyrethroids.

Usually pyrethroids kill by keeping tiny pores in an insect’s neurons from closing, leaving the bug in a continuously excited state – paralyzed. The New York bedbugs’ mutation strengthens the sodium channels (pores) in their neurons against that effect, making them up to 264 times more resistant, and letting them survive much longer when exposed to the insecticide, the study shows.

The wide spread use of DDT before it was banned, which also works on the sodium channels (pores) of an insects neurons, may have contributed to the evolution of this resistance, the authors report in their study. Finding a way to look for the specific mutations may help to monitor and prevent further resistance. In the meantime, you may want to stockpile the insecticide.