Any dog owner will tell you his dog understands what he's feeling—and now, science backs him up:  A new study confirms that dogs know when people feel happy or angry, and that they can understand the difference between the two.

"Our study demonstrates that dogs can distinguish angry and happy expressions in humans," Ludwig Huber, coauthor of the paper in Current Biology and researcher at University of Veterinary Medicine Vienna's Messerli Research Institute, said in a press release. "They can tell that these two expressions have different meanings, and they can do this not only for people they know well, but even for faces they have never seen before."

To understand whether dogs could decipher facial expressions, Huber and his team trained the pups to identify either happiness or anger by studying pictures. The canines looked at the faces of 15 different people, but not their whole faces—just half, to see if the dogs could understand emotions by simply looking at the eyes or the mouth. Half of the dogs received a treat when they identified the happy faces, and half the dogs received a treat for finding the angry face.

Then the dogs participated in four different tests: they examined the same half of the face they were trained on, but with different people; they looked at the other half of the faces they were trained on; they gazed at the other half of the new face; and the left half of the faces from training. Researchers asked the dogs to select either the happy face or the sad face, and the dogs made their picks by pressing their noses to a touch screen.

The dogs selected the angry and happy faces correctly enough that it can’t be attributed to chance—70 out of 100 times, the canines picked the right expression. Overall, dogs were better at finding the happy faces; the researchers believe that this means dogs understand the feeling behind the expression. And the study showed that dogs can take what they’ve learned from training and apply it to new situations—so once a dog learned what her angry master looks like, she could use that knowledge to identify an angry stranger.

“We conclude that the dogs used their memories of real emotional human faces to accomplish the discrimination task,” the authors write in the paper.

The authors also believe that the dogs know that a smiling face is associated with positive feelings while a scowl means something negative. “[I]t appears likely to us that the dogs associate a smiling face with a positive meaning and an angry facial expression with a negative meaning,” Huber says.