Warning: This post contains spoilers for How I Met Your Father season 2’s midseason finale

Neil Patrick Harris reprised his role as Barney Stinson in How I Met Your Father season 2’s midseason finale, and his return proved Barney’s controversial How I Met Your Mother ending was worth it. Barney’s story ended not with his marriage to Robin (or his divorce), but with the arrival of his daughter, Ellie, which changed his behavior for good.

Barney had a lot of growth throughout How I Met Your Mother’s nine-season run, but he did spend the majority of the show being a womanizer and generally disrespectful to the women he wanted to sleep with. However, when Barney began to fall in love with Robin, there was also a hint of change, and he tried his best to be a good boyfriend and, later, a good husband. How I Met Your Father season 2's midseason finale gives fans an update on Barney’s life after How I Met Your Mother’s controversial series finale — he’s now a SUV-driving, devoted dad who wears a shock device on his ankle that activates when he uses certain words.

How I Met Your Father Proves That Barney Changed For His Daughter Ellie

Barney meets Sophie in How I Met Your Father

While Barney attempted to change his ways while in a relationship with Robin, it was ultimately his daughter Ellie who brought about his permanent behavioral shifts. Barney was in full-on dad mode now, and spent time with his daughter, watching as Ellie’s relationship with his own father flourished. Even the shock device — while fairly extreme — proved that he wanted not only to be a better person, but the lengths he was willing to go to prevent himself from falling back into his old ways.

Before Ellie, Barney had to be pushed to apologize to women for manipulating them, and be convinced that his behavior was not the right course of action. How I Met Your Father proves that Ellie brings out the best in Barney, and that his changed conduct wasn’t temporary or a fluke. The fact that he now apologizes to women for his past misdeeds without being prompted by others is a major leap forward, and Ellie is to thank for these drastic alterations.

Why Barney & Robin's Divorce Was Right For Both HIMYM Characters

Neil Patrick Harris and Cobie Smulders in HIMYM - For entry Barney and The Robin play

Barney and Robin were married for three years before they decided to get a divorce. Although Barney and Robin's relationship was a decent chunk of How I Met Your Mother’s run, and their wedding weekend played out over the course of season 9, their divorce was not a huge surprise given the overall state of their partnership. Barney and Robin were on different paths, and they tried to make it work, but their divorce was the right thing for both of them at the end. It led to them being able to live out the lives they always dreamed.

Robin was able to become a well-known TV reporter, and Barney was able to focus on raising his daughter, becoming a better person because of her. If Barney and Robin hadn’t gotten divorced, Barney would have never had Ellie, and he would have continued being a womanizer with little chance for genuine, long-term change. Barney and Robin may have been right for each other for a time, but they needed to part ways so that they could fully invest in themselves and their future individually. Barney’s true relationship was with his daughter, and it’s only because of Ellie that he was able to become the man Sophie meets in How I Met Your Father.