The Office lasted nine seasons and created some of the most memorable characters to ever be on television. While we tend to focus on the most famous ones like Michael, Dwight, Jim, and Pam.

But attention should also be paid to Andy "I went to Cornell" Bernard. 

Andy had one of the weirdest and most bumpy arcs on The Office. In watching the character grow from annoying supporting player to an increasingly likable lead character, you can tell what the writers liked working with Ed Helms and wanted to reshape his character and tailor it more to the actor's strengths and on-screen likability.

It's an excellent study in altering your plans when a better path forward opens up. 

So watch this video from Nerdstalgic that dives deep-ish into how all that works:

How 'The Office' Saved Andy Bernard In One Episode

Sometimes great characters just fall into your lap. and that's what happened when showrunner Greg Daniels took a meeting with Ed Helms. It was supposed to be a general meeting, but the two hit it off right away. 

Helms had an idea for a character who was the ultimate annoyance. Someone who could get under everyone's skin. 

And that's how Andy Bernard was born. 

Andy was a character brought in to be the anti-Jim. He was supposed to make Jim feel like he made a mistake leaving Scranton and make his world harder. When the merger happened he was supposed to be one of the last to go. 

Especially after he punched the wall.

But Daniels and the other writers really liked Ed Helms and wanted to bring him back. Still, their plan of making Andy a villain had worked perfectly. He was despised by all and it seemed like there could be no way to bring him back. 

That's where great writing kicked into gear. They knew that the only way to keep Andy would be to change his character. And they knew they only had one episode to do it. The audience who loved the show despised Andy, so they were going to be against it. 

They had catharsis when he was tossed after punching the wall... 

Still, the writers thought it was worth the risk. And it paid off with the episode, "Safety Training."

The plan to bring Andy back was a simple one. Say he went to anger management and slowly insert him into the series. When Andy comes back, we chat with him in the cold open, learn he wants to change his name to Drew, and...that's it. 

See, Andy was such a loud and bombastic presence that he would never fit in the office. They already had that guy in Michael. And he couldn't remain Jim's foil because they already had Dwight. 

So they turned Andy into just another weirdo. 

The Office became a perennial favorite because of all the people that worked there. And to keep Andy, they just blended him into the fold. Everything that used to be cranked to 11 on Andy got notched down so that he could become part of the background. 

In the episode of his return, we see Michale put himself in danger and get more on the Jim and Pam romance. andy has a part in the cold open, but he's just comic relief the rest of the time. 

So to keep Andy, The Office writers hid him in plain sight. 

As the season went on, Andy was just there for the laughs. And we even dug more into his damaged backstory, got him a romance with Erin and softened him up. Suddenly people liked Andy Bernard -- and the slight of hand of a character was complete. 

It was truly an epic almost heist of a way to insert him into our lives and that character was embraced. 

But then Ed Helms did The Hangover and got super famous and needed time off to shoot the sequel, so the writers made Andy a tool again and he never really recovered. Sadly.

Still, there were some really amazing seasons in between that made us love him and love the choice to keep him. 

So when you're writing, don't be afraid to deviate from your best-laid plans. 

Just make sure you have a new plan that makes sense and maybe the best team of sitcom writers of all time who support you. 

What's next? How did The Office save Michael Scott

During the first season of The Office, the show relied on the character tenets of the British version to put forth a meaner, less redemptive Michael Scott.

American audiences were not feeling it.

Click to learn more!