If your four-legged friend wanders into your bedroom when you're trying to sleep, it may be best that you don't shoo the pooch away, a study has found.

An astonishing new report from the Mayo Clinic suggests that humans may actually sleep better when their dogs are in the bedroom with them, meaning that kicking them out might not be such a great idea. The study determined that having a dog in your room with you while you sleep may improve the quality of your sleep, although that doesn’t hold true if your dog is in the bed with you.

The Mayo Clinic study, titled “The Effect of Dogs on Human Sleep in the Home Sleep Environment,” is based on an examination of 40 people who owned dogs and didn’t suffer from any sleep disorders. They put accelerometers on both the dogs and the humans for seven nights, and then examined the results.

They were surprised to find that if a dog is in the bedroom, people had a greater sense of comfort and security. But if the dog was actually in the bed, people had a lower sleep quality than normal. So while it’s OK to ban your dog from the bed, maybe it’s fine to have him or her sleep in a doggie bed in the bedroom with you.

“Most people assume having pets in the bedroom is a disruption,” says Lois Krahn, M.D., a sleep medicine specialist at the Center for Sleep Medicine on Mayo Clinic’s Arizona campus and an author of the study. “We found that many people actually find comfort and a sense of security from sleeping with their pets.

“The relationship between people and their pets has changed over time, which is likely why many people in fact do sleep with their pets in the bedroom,” says Dr. Krahn. “Today, many pet owners are away from their pets for much of the day, so they want to maximize their time with them when they are home. Having them in the bedroom at night is an easy way to do that. And, now, pet owners can find comfort knowing it won’t negatively impact their sleep.”