It’s the moment every parent waits for—their baby’s first smile. This usually occurs around four weeks of age, but some babies may not smile until they are three months old. Parents often wonder why their baby is smiling. Some believe it may be in response to gas, but there’s actually another surprising reason behind those first smiles.

A recent study found that babies actually smile to make their parents smile. From very early on, babies learn that when they are happy, their parents are happy. It’s an important early social skill that will often predict how well they will interact with others later on in life.

Even more surprising, babies often reserve their smiles for specific times in order to maximize the joy their parents feel. After their first few tentative smiles, babies quickly discover that if they space out their smiles throughout the day, they will keep their caregivers smiling on a regular basis. On the other hand, if they stop smiling or don’t smile frequently enough, they realize that their parents stop smiling as well.

Babies are very intuitive when it comes to emotions, specifically with their mother’s emotions. During the study that was conducted by the University of California in San Diego, researchers found that babies focused on making their mother smile as much as possible while doing as little work as possible in the smile department. On the contrary, mothers worked to maximize the amount of mutual smile time between both themselves and their infants.

As babies get older, they start equating smiles with happiness. By the age of nine months, most babies begin smiling at objects that bring them delight. They may find joy in a particular toy or stuffed animal. Once they move on to anticipatory smiling, which is smiling at an object and then turning that smile towards their caregiver, they have reached another important milestone.

Anticipatory smiling is considered a sophisticated social skill and is a good indicator that children will have healthy social interactions as they get older. A 2009 study published in Infant Behavior and Development showed that babies that engaged in anticipatory smiling regularly at nine months of age were more likely to score higher on social competency tests conducted at age two and a half.