A viral video of a man viciously beating his dog has resulted in a happy ending. On Friday, animal rescuers tracked down the man and refused to leave his home until he surrendered his dogs to their care.

In the video, the man sits in a cart and beats his dog with a stick—presumably trying to force the small dog to pull him forward. The dog is chained to the cart. She lies down on the street, unmoving, while he beats her.

Warning: the footage below is disturbing.

The video was filmed in Shanghai, China and posted online on Nov. 2.

Shanghai has no legislation protecting animals from abuse. In an interview with Forbes, expert Peter Li describes how China’s government chooses profit over animal rights — especially in relation to factory farming — because the nation is concerned that animal cruelty legislation would slow down meat production.

But in recent years, people have taken action to end abuse suffered by animals in China. Earlier this year, activists protested the Yulin Festival, an annual festival where traders bring dogs from all over the world to butcher. They were able to save more than 1,000 dogs from slaughter.

According to Jason Baker, PETA’s Vice President of International Campaigns, the man from the above video was the owner of two dogs. He kept both dogs chained outside to his balcony.

Once PETA Asia saw the horrifying footage, the animal welfare group started their search for the man, Baker told Lady Freethinker.

“PETA Asia’s investigators carefully examined the video and contacted someone at the headquarters of a store seen in the background, “ said Baker. “Within an hour, they learned the location of that particular branch of the company, and PETA Asia’s team in Shanghai immediately left to go directly there. Neighbors confirmed the area where the man lived and his apartment number. No one answered the door, so our staff waited it out, prepared to camp there for the night if necessary.”

Eventually, the man handed over the dogs and they were taken to a safe place.

According to Baker, the dogs have been seen by a veterinarian. PETA Asia is searching to find them a forever home.

“They are wary and still in the early stages of learning to trust humans and to walk on leashes,” said Baker. “Both love sleeping in a comfy bed indoors with their foster guardians.”