The carnivorous pitcher plant Nepenthes bicalcarata, found in Borneo, has a perplexing double life: Although it eats ants, it also serves as home to one ant species.

Now a new study reports that the resident ants — Camponotus schmitzi — hunt down mosquito and fly larvae that breed in the plant, preventing the larvae from stealing its nutrients.

“The digestive fluid of the plant is not that aggressive, so mosquito larvae and fly larvae can survive,” said Mathias Scharmann, a doctoral student at the Swiss Federal Institute of Technology in Zurich and an author of the study, which appears in the journal PLoS One. (At the time of the research, he was a student at the University of Würzburg in Germany.)

The researchers analyzed the pitcher plant’s stable isotopes to identify the origin and abundance of its nitrogen, a nutrient crucial to its health.