Let’s say you’re out hunting with some friends, and all of the sudden you are all gruesomely attacked. One of your buddies loses a leg or an arm. As you’re running for dear life, would you pick up your injured friend and carry him to safety? Or would you leave him behind to die? If you picked the former, congratulations! You’re as evolved as a termite-hunting ant called Megaponera analis.

M. analis live in sub-Saharan Africa, and they love eating termites. When they’re hunting their prey, however, these ants often get injured — they lose legs, for instance. When that happens, the healthy ants pick their injured friends up and bring them back to the nest, where they can recover, according to a new study. The ants aren’t doing this out of the goodness of their hearts, however. Their “selfless” behavior is practical: when the injured ants recover, they take part in raids again — sometimes less than an hour after injury. So instead of dying, these ants remain functioning members of the colony — and that benefits all the ants.

In nature, helping or rescue behavior “is actually not as widespread as one might think,” says study author Erik Thomas Frank, who researches animal behavior and evolution at the University of Würzburg in Germany. Rats sometimes help free other trapped rats and elephants rescue other elephants when they’ve fallen into a hole or water. Monkeys and apes are also known for helping their fellows — bringing water to an incapacitated individual or slowing down travel pace to accommodate an injured mate. In insects, there are only two examples of rescue behavior, Frank says, and both are in ants: the animals sometimes dig other ants out when the nest caves in, and some ants try to rescue others when they’re attacked by antlions — insects that feed on ants.

In both of those cases, the ants are prompted to help because a peer’s death is imminent. Today’s study, published in the journal Science Advances, shows a more complex rescue behavior, Frank writes in an email to The Verge. With M. analis, in fact, the danger is not as obvious. An injured ant might not die — it’s possible the ant will heroically drag itself back to the nest. “The ants are not capable of calculating the mortality risk an injured ant would have if it would return alone,” Frank says. But somehow, they have evolved to take into account that risk, and intervene to rescue their mates. “This is even more astonishing,” Frank says, because this behavior hasn’t evolved in highly intelligent animals like apes or elephants, but in “a relatively simple organism.”

M. analis ants specialize in raiding termite nests, as often as four times a day. Anywhere from 200 to 500 ants march in columns that stretch up to 164 feet away from the nest to mount an attack. (For reference: that’s about as long as the Niagara Falls are tall.) During these raids, some ants die from decapitation, or loss of other vital body parts. Some ants are only injured, losing legs or antennae, or are handicapped by termites that cling to their bodies. When that happens, healthy ants often carry the injured ones back to the nest where the termites are removed and the ants can recover. (The dead ants are left behind.)

Frank and his colleagues observed wild colonies of these ants in the Ivory Coast savanna woodland, painting some of them with acrylic colors so that they could be easily tracked. In various experiments, the researchers saw that when injured ants were forced to return to the nest alone, they had a 32 percent chance of dying — mostly because they were snatched by spiders. Instead, when the injured ants were aided by other ants, the mortality risk went down to zero. Almost all of the rescued ants took part in following raids, sometimes less than an hour after the injury.

That means that saving the injured has a benefit for the colony as a whole: it allows the colony to maintain the same size without needing to give birth to new ants, Frank says. “The life of the individual ant is not of primary concern,” he says. Colonies where ants help the injured are estimated to be almost a third larger than colonies where the injured are on their own.

These ants come with their own SOS signals — pheromones that are triggered when an ant is injured. The compounds basically alert the healthy ants to the need for a rescue mission. That’s different from the mechanisms that trigger people to help someone who’s injured: empathy, or the ability to put yourself in someone else’s shoes. “This is not an altruistic behavior,” Franks says. “The ants do not help the injured out of the goodness of their hearts.”

Now, Frank wants to keep studying the ants, understand how they treat the injured in the nest, and whether they’re able to distinguish between injuries. (Is a severed leg considered more severe than a termite biting on an ant’s body?) He’d also like to know if a similar, complex rescue behavior is found in other species that hunt in groups and sustain heavy injuries. Highly intelligent animals, raise your hand (or paw) if that’s you!