Ridley Scott’s Blade Runner has long been considered an untouchable cinematic masterpiece on par with Casablanca or Gone with the Wind. As the first and still the greatest tech noir, it’s a cornerstone of science fiction. When Denis Villeneuve was hired to direct a belated sequel to Scott’s movie, it seemed doomed to fail. Villeneuve might as well have been hired to direct Goodfellas 2 or Apocalypse Now 2.

And yet, by some miracle, Villeneuve pulled it off. Released 35 years after the revered 1982 original, Blade Runner 2049 followed in its predecessor’s footsteps with universal critical acclaim followed by box office disappointment. How exactly did Villeneuve manage to make a Blade Runner sequel that did the impossible and satisfied a ravenous cult sci-fi fanbase?

RELATED: One Movie Both Invented And Perfected The Tech Noir Genre

Coming up with a premise for a sequel is tricky, because the point of a sequel is to replicate the success of the original, but sticking too closely to the established formula will feel like a pointless rehash. Most sequels end up repeating the first movie with one key change. In Die Hard 2, John McClane once again has to save his wife from a hostile takeover – but this time, it’s in an airport, not a skyscraper. In The Hangover Part II, the Wolfpack once again goes on a bachelor party and loses a guy – but this time, it’s in Bangkok, not Vegas. In Home Alone 2, Kevin McCallister is once again left alone by his family and targeted by the Wet Bandits – but this time, it’s in New York, not Chicago.

Ryan Gosling as Officer K in Blade Runner 2049

The best sequels do something to raise the stakes from the original, like Aliens replacing the single extraterrestrial menace of the first Alien movie with a hive full of dozens of them, or build on its themes, like Vito’s early rise running alongside Michael’s corruption in The Godfather Part II. One way to follow up a beloved movie with something that feels fresh and new while still maintaining the spirit of what attracted fans before is to smartly subvert the familiar formula. In Terminator 2, Arnold Schwarzenegger’s T-800 becomes a protector, while an even more powerful Terminator is the new villain.

It’s the latter technique that makes Villeneuve’s Blade Runner sequel work so well. He made a movie with essentially the same premise as the original, but flipped on its head. Scott’s movie was told through the eyes of Rick Deckard, played by Harrison Ford, a supposedly human hard-boiled detective who reluctantly takes a job as a “blade runner” hunting down replicants and begins to suspect that he might be a replicant himself. Villeneuve’s sequel is similarly told through the eyes of an L.A.-based blade runner, but Ryan Gosling’s Officer K is a supposed replicant who begins to suspect he’s a human. The telltale sign of a replicant is their implanted memories, but K thinks his memories could be unique (and therefore real).

By focusing his own Blade Runner story on a similar identity crisis to the first movie, Villeneuve was able to tap into the same existential themes that Scott’s film touched on. The story of an android who thinks he’s a human is completely different than the story of a human who thinks he’s an android, but they both tap into the same thought-provoking ideas. Both movies beg the same question from their own angle: if artificial intelligence can blend into human society and become indistinguishable from real people, then what really constitutes a “real” person?

Officer K on a post-apocalyptic wasteland in Blade Runner 2049

One of the biggest fears about the Blade Runner sequel was that it would ruin the ambiguity of the original. Scott’s original Blade Runner leaves it unclear whether Deckard is really a replicant or not, and following up that cliffhanger ending seemed to promise a definitive answer to one of cinema’s most effective unanswered questions. Fortunately, Villeneuve understood that a lot of the power of Scott’s movie came from the ambiguity of Deckard’s identity, so he left that ambiguity intact in the sequel and instead provided answers elsewhere, like the heartbreaking outcome of Deckard’s star-crossed relationship with Rachael.

Taking a human protagonist who might be a replicant and replacing him with a replicant protagonist who might be a human isn’t the only reason Blade Runner 2049 is a satisfying follow-up to Scott’s classic. Villeneuve took audiences outside the Blade Runner universe’s dystopian Los Angeles to explore gorgeously designed post-apocalyptic visions of Las Vegas and San Diego. In addition to expanding the worldbuilding in the literal sense, Villeneuve also introduced A.I. girlfriends and reproductive androids into this curious futuristic world.

But impressive worldbuilding would be meaningless without a plot that can captivate audiences and get them invested in the next chapter of this mind-bending sci-fi opus. The morally dubious story of a replicant tasked with hunting replicants harks back to the classic noirs that inspired Blade Runner, then the revelation that K could be the fabled human child born to a replicant mother harks back to the mysteries of Blade Runner itself. Unfortunately, the fate that K ultimately meets is closer to Roy Batty than Rick Deckard.

MORE: Harrison Ford Reads Brutal Studio Notes On 'Blade Runner' During Oscars