A storyline in Person of Interest season 2 with John Reese (Jim Caviezel) and his former partner set up how the team defeated Samaritan in the series finale. Created by Decima Technologies, Samaritan was an advanced A.I. imagined as the evil equivalent of the Machine. After going online at the end of season 3, Samaritan became the country’s primary surveillance system and the biggest threat to the team.

Throughout seasons 4 and 5, Reese and Finch (Michael Emerson) tried to fight Samaritan under the radar, knowing that the A.I. was able to see everything that they did. The existence of Samaritan put them in more danger than ever, but after several battles, the team overcame the odds and found a way to beat their enemies. Finch found an incredibly dangerous computer virus called “ICE-9” and determined that it alone was capable of taking down Samaritan for good. Finch was able to dispose of Samaritan by uploading ICE-9 into its systems. Once weakened, it was taken out completely by the Machine in the Person of Interest series finale (thanks to Reese’s decision to make the ultimate sacrifice).

Related: Person of Interest: How Finch & Reese Found Their Dog, Bear

ICE-9 itself first entered the picture in the season 5 premiere, but as Person of Interest showrunner Greg Plageman has pointed out, the idea of a virus like ICE-9 had been brought up in the past [via TVLine]. Back when Reese was still being employed by the CIA, he worked alongside an experienced agent named Kara Stanton (Annie Parisse). Years later, Kara became an enemy of the team. In season 2, she was supposedly trying to steal a top-secret, powerful virus called Cygnus that could create all sorts of chaos by bringing down the internet and the Machine at the same time. Reese tried to stop her, but it was revealed that Kara actually had other plans. On orders given to her by John Greer (John Nolan), Kara uploaded a virus she was already carrying to the government’s servers. Apparently, the intended target was the Machine. The virus hurt the Machine and caused it to stop providing Reese and Finch with numbers for several days.

Person of Interest

Person of Interest’s Kara Stanton story in season 2 introduced the concept of a doomsday virus that’s so advanced that it can destroy any computer system – even the Machine. Though Kara’s search for Cygnus was actually just a red herring and never her real plan, it served an important purpose. It established the idea that such a virus does indeed exist in the world of Person of Interest.

Plageman explained that using a virus like this was a “long-haul decision” and a “nuclear option” because it would end the Machine and do damage to the global economy. Given everything that they went through to beat Samaritan and the danger it posed, the stakes were at their highest in Person of Interest season 5, making it necessary for a virus like ICE-9 to be unleashed on both the Machine and Samaritan. Thankfully, the Machine survived, but only because they managed to preserve a duplicate of it.

More: Everything Person of Interest Revealed About Reese's True Identity