Caffeine is likely the world’s most popular psychoactive drug. In the U.S., an estimated 90% of adults consume it daily, either in coffee, tea, soda or energy drinks.

A new study published today in Science found that the drug isn’t just popular among humans. A group of scientists from Newcastle University in the UK and elsewhere found that low doses of caffeine are present in the nectar of coffee flowers and many types of citrus plants—and that when the honeybees imbibe the drug while foraging, they demonstrate measurably improved memory for a particular floral scent afterward.

The research team, led by Geraldine Wright, measured the levels of caffeine present in the nectar of three types of coffee plants (robusta, arabica and liberica) along with four different kinds of citrus (grapefruit, lemons, pomelo and oranges). All nectars studied contained slight amounts of the drug—with the coffee nectars containing more than the citruses—and all nectars are commonly consumed by honeybees in the wild.

To see exactly what effect this caffeine has on honeybees, the scientists investigated what the drug did to bees in a lab setting. First, they trained the insects to associate a particular floral scent with a sugar and water solution: They gave the honeybees a drink of the sugar mixture if they extended their proboscis immediately after smelling the aroma; after a number of trials, all the bees were conditioned to perform the action upon being exposed to the scent. For some bees, though, the researchers had introduced varying levels of caffeine into their sugar solution.

When the bees’ memory was tested 24 hours later—by checking if they still responded to the scent by immediately extending their proboscis—those that had caffeine in their solution demonstrated notably better memory for the scent. They were three times more likely to perform the action, and even after a full 72 hours, they were still twice as likely to remember the aroma.

The findings shed light on what had long been a caffeine mystery. The drug, which is bitter when tasted in isolation, has conventionally been thought of as a defense mechanism for plants, reducing the chance that they’ll be eaten by herbivores.

In this context, botanists had long wondered why bitter caffeine is present in low doses in nectar. The sweet liquid is produced to attract bees, insects and other animals that serve as pollinators, spreading pollen between individual plants of the same species to aid in reproduction—so why would a bitter defense mechanism be included?

The levels of caffeine in the nectar of all the plants studied, it turns out, are too low to taste bitter to the bees, but just high enough to provide the memory boost. This happy medium could provide a benefit for both the bees and the plants.

“Remembering floral traits is difficult for bees to perform at a fast pace as they fly from flower to flower,” Wright, the lead author, said in a press statement. “We have found that caffeine helps the bee remember where the flowers are.” As a result, the drug gives bees the ability to more quickly find flowers that provide valuable nectar—and plants are provided with more frequent pollination from the insects.

The researchers hope that their findings will do more than let coffee drinkers know they share something in common with honeybees. In an era when crashing populations of honeybees and other pollinators are getting scientists concerned about the yields of dozens of pollinated crops and wild plant biodiversity, a better understanding of the bee foraging and pollination process could be crucial for finding a solution.