TV show South Park was clearly making fun of a viral video titled “What, What (In The Butt)” when it made its own version, and was therefore not breaking the law, a court has ruled.A federal appeals court in Chicago deemed the South Park video “fair use” Thursday after noting some key differences between the South Park video and the one that inspired it.

The South Park parody, featured in the show’s “Canada Goes on Strike” episode, features its character Butters dancing around while singing “What, What, (In The Butt.”

That video is a parody of a real-world viral video with a man singing and dancing in tight pants, which has been seen by 47 million people on YouTube.

“However, the South Park version stars Butters,” the appeals court ruled, “a naive 9-year-old, in a variety of costumes drawing attention to his innocence: at various points, he is dressed as a teddy bear, an astronaut and a daisy.”

The makers of the real-life video sued the South Park creators, and a lower court previously dismissed the case.