While Skyfall killing off Judi Dench’s M was a moving, shocking end to the 2012 James Bond movie, the twist was almost ruined by Die Another Day years earlier. The tone of the James Bond series could not have changed more between Pierce Brosnan and Daniel Craig’s movies in the role. Brosnan’s Bond was a smirking, self-aware ladykiller whereas Craig’s brooding James Bond was a self-serious, unsmiling secret agent wracked by guilt and PTSD.

Some critics of Craig’s James Bond even (inaccurately) claimed that he had fewer love interests than his predecessors, which is a testament to the extent that the James Bond franchise transformed the character’s persona between Brosnan’s reign and Craig’s time playing the part. However, there was one pivotal part of Brosnan’s Bond tenure that survived Craig’s arrival. Judi Dench’s no-nonsense incarnation of Bond’s boss M was introduced in Brosnan’s first movie, but remained a part of the series until 2012’s devastating Skyfall.

Related: Daniel Kaluuya Is Right: Why He’s A Perfect Bond 26 Villain

Near the end of Skyfall, M was killed off by Javier Bardem’s Silva in a twist that confirmed no one was safe in this darker, more mature iteration of the franchise. No Time To Die’s massive twist was foreshadowed by Skyfall’s revelation that M could be killed onscreen - the first evidence that the 007 franchise was willing to canonically kill off a major character. However, the tragic and utterly unexpected death of Bond’s boss was almost derailed by Die Another Day’s original draft, which would have seen Dame Judi Dench’s M retire and be replaced by Edward Woodward years before Craig even took on the role of Bond.

How Die Another Day Nearly Ruined Dench’s M Exit

Judi Dench as M in Skyfall with Daniel Craig as James Bond

Die Another Day’s campy script originally had a significantly less dramatic end for Dench’s iteration of M that would have sapped the character's story of all of its pathos. Craig’s connection to Dench’s M made their dynamic effective and her death tragic, as he relied on her for emotional support as well as professional guidance. Bond’s betrayal by his love interest in Casino Royale made it tough for Craig’s 007 to trust anyone, which turned his willingness to follow M’s guidance into a sign that he was gradually healing this psychological wound. Bond’s discovery that M had been lying to him for years was already a tough blow early on in Skyfall’s story, while her death was a brutal moment that left the character heartbroken.

However, all of this emotional impact would have been undone if Craig’s Bond had been working with Woodward’s M since it is unlikely that he would have had the same rapport with the character. While the British star would have been a solid choice as Brosnan’s Bond boss, it was Dench that made the M’s Skyfall death so impactful. Dench explored the humanity underpinning the character for the first time in the James Bond franchise’s long history, making her Skyfall death a tough shock for audiences.

Next: How Daniel Craig’s James Bond Debunked The Biggest Fan Theory Over 5 Movies