This article contains spoilers for "How I Met Your Father."

Somehow, despite the odds being stacked against it, "How I Met Your Father" is fantastic. The sitcom captures the essence, the shenanigans, and the slightly unreal tone of the original while updating it slightly for modern times. We have a more diverse cast and more modern problems — like the characters actually struggling financially while living in New York and not having insurance, all while the show justifies why the characters would still spend all their time at a bar.

"How I Met Your Father" is also slowly bringing back the cast of the original for some fan service but in cool little ways. First, it was Robin, who happened to just be hanging out at a familiar bar and offered Sophie some advice. Now, the show just brought back another character … Barney Stinson.

Barney was arguably the most popular character of "How I Met Your Mother," the Fonzie of the "How I Met Your Mother" universe, and also its most problematic character. He's a slimy jerk who lied, tricked, and bamboozled women into sleeping with him and treated them as objects. His return was actually announced from the very beginning of the season, and it could have easily been a very self-indulgent fan service moment. Thankfully, it wasn't.

Instead, the mid-season finale of "How I Met Your Father" finally brought Barney to justice and gave him what he deserved — with enough electricity to power the entirety of Staten Island.

A Legend — Wait For It — Dary Cameo!

In the two-part mid-season finale, Hilary Duff's Sophie starts dating an older guy and starts suspecting that he may be her father. In a frenzy, she runs away from his house and crashes into a car with the license plate LGNDRY. Out of that car comes out Neil Patrick Harris' Barney.

He is still very much his old self, making crass and lewd comments at Sophie, but we do get the feeling he's changed a bit or is at least trying to. He starts by apologizing to Sophie, introducing himself as a "recovering serial womanizer" and assuming she is someone he slept with who is seeking revenge, listing off some of the hundreds of schemes he's done over the years. Also, he says he's going to therapy.

Of course, this is "How I Met Your Father," which already illustrated this very season that therapy doesn't magically solve all your problems — especially when you're not actually going to therapy but asking your friend with insurance to ask their therapist for advice on your problems instead.

As for Barney, he explains that he now has an STD: a shock therapy device. Every time he says something problematic, he is blasted with "enough electricity to power Staten Island."

This is the best-case scenario for a Barney return. The electro-shock device gives the show an opportunity to have Barney still be the hilarious character fans fell in love with almost two decades ago (!!!) while also finally making him pay for every gross thing he says, rather than just excuse his behavior with the shrug emoji like every character did in the original show.

Growing Pains

The thing is, as wacky as it is, the shock therapy device is a perfect "How I Met Your Mother" gag. Is it a bit on the nose? Of course, but this is Barney we're talking about! He is a man-child who lives in a Looney Tunes reality filled with gadgets worthy of Inspector Gadget (or Wile E. Coyote), and who would gladly accept the challenge of trying to go without hitting on a woman or else he gets electrocuted.

But his cameo is more than just a one-off joke, it serves as another seminal teaching moment for Sophie just like the Robin cameo in season one. Here Barney tells Sophie of how he found his father and it improved his life but didn't fix it, and how even the birth of his daughter didn't fix him, though it did inspire him to try to change, which then prompts Sophie to want to find her father at the end of the episode.

So far, the cameos in "How I Met Your Father" have served cool little plot purposes, the same way many of the side characters were mostly there to teach Ted a lesson in the original show. Both sitcoms are all about how personal relationships help us grow, and how, to quote the great poet and philosopher from the hit TV show "Lost," Dr. Christian Shephard, "Nobody does it alone. You needed all of them, and they needed you."

Sure, it would be great for any of the other main characters to meet Marshall or Lily or someone else, but it makes sense for Sophie's journey to be informed by all these random people she meets once but has a profound impact on her life. What's more "How I Met Your Mother" than that?

Read this next: 12 Underrated Sitcoms That You Should Check Out

The post How I Met Your Father Brought A Legacy Character to Justice appeared first on /Film.