How I Met Your Mother nearly ended after it aired its eighth season. Here’s why the network gave the series another season, and how getting to the end was more complicated than expected.

The series ultimately ended in the spring of 2014 and is still considered one of the best sitcoms in recent history. Its innovative method of storytelling has allowed How I Met Your Mother to stand out from the rest. The show was told through future Ted’s narration as he recounted to his kids about how he met their mother. The plot device allowed the series to jump back and forth between time but it ultimately created the major mystery centering around the identity of the “Mother.”

After years of stories focusing on Ted (Josh Radnor), Robin (Cobie Smulders), Barney (Neil Patrick Harris), Marshall (Jason Segel), and Lily (Alyson Hannigan), the Mother was finally revealed in the season 8 finale. Tracy McConnell (Cristin Milioti) then became a main character for the ninth and final season. That last season received mixed reviews from audiences, but it almost didn’t even happen. The show’s co-creators Craig Thomas and Carter Bays originally imagined an eight-season run following the pilot episode up until the extension. So how did How I Met Your Mother season 9 come about?

Throughout the show’s run, the cast and crew thought it would only run until season 8. CBS ordered the eighth season in 2011 but a recent resurgence in viewership caused the network to rethink the future of How I Met Your Mother. However, for the show to run past season 8, the contracts for the cast would have needed to be re-negotiated. Everyone was on board except for Jason Segel, who wanted to focus on his film career. The negotiation process was tough but they ultimately convinced Segel to do another season. CBS announced the renewal shortly after Segel’s contract agreement.

During the negotiation process, Thomas and Bays continued with their original plan in case the series was to end with season 8. The path would have led to Victoria being revealed as the Mother as she was a character that appeared in multiple seasons. She was highly theorized to be the titular character but there were obvious gaps in the continuity details previously linked to the character.

In the end, CBS gave Thomas and Bays the opportunity to hire Cristin Milioti as the long-awaited Mother. She appeared for the first time in the season 8 finale before becoming a mainstay in the final season. Milioti was an enticing addition to the cast and her character as Tracy was able to resolve many unanswered questions. The ending of How I Met Your Mother may have felt rushed but it was a better option than cutting the series in 2013. Just think of all the abandoned storylines if Thomas and Bays kept up with their original plan.

Next: How I Met Your Mother: Slap Bet Rules & All 8 Slaps Explained