Riverdale paused its usual crazy shenanigans in the Season 4 premiere to host an entire episode dedicated as a tribute to the late Luke Perry. The beloved actor died in March at age 52 after suffering a massive stroke, and The CW’s Archie Comics drama paid respect by sending off his character Fred Andrews in the most heroic of ways.

At the very beginning of the season 4 premiere, Archie (KJ Apa) receives a call letting him know that Fred was struck by a car. Throughout most of the episode, he struggles with accepting his father’s death and tries to figure out how and why the accident happened. When he visits the site of the accident, he sees a woman (played by Perry’s 90210 costar Shannen Doherty) laying flowers on the side of the road. When he asks her why she’s bringing flowers to the place his father died, she reveals that she was stranded on the side of the road and Fred was the only person who stopped to help her with her car. That’s why he was hit by a car that came speeding by.

After confronting the man who turned himself in for the hit-and-run, Archie learns it was actually the man’s underage son who was driving without a license who accidentally hit Fred. The father was just covering for his son to protect him. Archie realizes that’s something he could have done—sneaking out and taking the car without permission, getting into an accident—and his father would have done the same thing—taking the blame to protect him. It really was just an accident. By the end of the episode, Archie vows to live his life in a way that would make his father proud.

Credit: Robert Falconer, The CW

Riverdale honors both Fred and Perry with a parade put on by the whole town, and reminiscing with videos and photos of both the character and the actor while setting off a beautiful fireworks display.

Showrunner Roberto Aguirre-Sacasa reveals that the initial plan was to wait on addressing Perry’s death on the series.

Credit: Robert Falconer, The CW

As for why he decided to write Perry’s exit as a death onscreen, Aguirre-Sacasa explains that was a very conscious choice. “Very early on, we landed on the idea that Fred should have a heroic death and that would be impactful for Archie,” he says. “It felt like that’s a way that Fred could have gone. After that, we said this episode really isn’t going to launch any huge stories for this season. It was really going to be focused on that and the emotional effects of that passing for everyone.”

There had been some talk about including some other Riverdale storylines in the premiere, but each time he decided against it.

“There have been sadly a lot of tribute episodes in television—one of my favorites is the Friday Night Lights episode where the football player’s father dies, called ‘The Son,’” Aguirre-Sacasa says. “We wanted to tell a very grounded, truthful story. That became the organizing principle or the marching orders.”

And while Doherty’s cameo was short, having her involved in this tribute episode was important for the showrunner.

When Riverdale picks up in the next episode, it’s going to return to business-as-usual with storylines left on cliffhangers back in the season 3 finale. But Aguirre-Sacasa promises that “Fred casts a long shadow” and his death will continue to impact the series moving forward.

Credit: Robert Falconer, The CW

One of the ways that the showrunner wanted to honor Perry’s memory was to include footage and photographs of him in the episode. The footage came from already-aired episodes in the past, but the photographs are actually from Perry’s life.

The process of making this episode was “brutal” on the cast—“especially KJ,” Aguirre-Sacasa reveals—but in the end, “everyone was really proud to gather to tell this tribute to Fred and to Luke… That was cathartic.”

Riverdale airs Wednesdays at 8 p.m. on The CW.