Scientists discover how to stay on the right side of your dog