If you’re still wondering how Eminem wound up performing at this year’s Academy Awards, credit Justin Timberlake for the idea — sort of.

Timberlake opened the 2017 ceremony with a performance of his hit “Can’t Stop the Feeling,” and since then, the Oscars has embraced including high-energy musical numbers to liven up the telecast. Last year, Queen featuring Adam Lambert opened the awards with “We Will Rock You,” an ode to that year’s nominated film “Bohemian Rhapsody.”

But since that Timberlake performance, ABC Entertainment alternative/specials/late-night senior VP Rob Mills said the network and the Academy had been looking for a way for Eminem to finally, much belatedly, perform “Lose Yourself” during the Oscars.

“It’s something we’ve talked about for years,” Mills told Variety on Monday. “Because that was one of the great film anthems of all time, and anthems all together. But it’s one that he never performed on the Oscars. After Justin opened the show with ‘Can’t Stop the Feeling,’ you saw how a number like that can really inject some energy into the show.”

The breakthrough came with Oscars producer Lynette Howell Taylor, who was a producer on last year’s “A Star Is Born” — which featured a soundtrack released by Interscope (Eminem’s label). “Lynette had a relationship with Eminem’s people and Interscope, and I think she’s the one who made miracles happen and got him out there,” Mills said.

“Lose Yourself,” from Eminem’s semi-autobiographical film “8 Mile,” won the Oscar in 2003 for best original song. But the rapper wasn’t in attendance, and at the time, some reports suggested that Academy officials were nervous about having him perform — and potentially curse — on the live broadcast. But in a 2015 interview on his SiriusXM radio station, Eminem said he simply skipped the ceremony because he didn’t think he would win — and didn’t understand the symbolism of the award. “I always thought like rap never gets as fair shake on anything. That was one of the reasons I didn’t go for the first Grammys I was invited to,” he said at the time.

That changed this year, and after it was done, Eminem was clearly pleased: “Sorry it took me 18 years to get here,” he wrote on Twitter. But up until the day of the telecast, it wasn’t clear if he’d actually perform.

“Lynette really kept [the secret] high level, and I think it was really on a need-to-know basis for people,” Mills said. “For him, the most important thing was secrecy. I think he might have backed out if it had leaked. I think on Saturday or Sunday if it had leaked, he might say, ‘No, people know about it, I don’t want to do it.’ He really wanted this to be a surprise.”

“Lose Yourself” took place in the middle of the telecast, and that scheduling was on purpose: Had Eminem backed out, removing the number from the run of show wouldn’t have had much impact on the telecast. Instead, the opening number went to Janelle Monae. “Lynette and Stephanie [Allain] wanted to do a big, huge, energy-infused opening number,” Mills said. “We saw with Justin and then last year with Queen, you can not put a price on opening the show with energy like that. It was also great seeing people say, ‘This reminds me of the old-fashioned Oscar openings, but with fresh energy and a new voice.'”

Lazy loaded image

Meanwhile, without a host, the producers emulated last year’s formula of bringing on a comedy team to perform an opening monologue. Last year it was Tina Fey, Amy Poehler and Maya Rudolph; this year, it was Steve Martin and Chris Rock.

“You need comedy and you need commentary on the nominations,” Mills said. “Obviously those are two comedy geniuses so when we heard they wanted to do it, that was amazing. There were a lot of different ideas, but you need to open, after the music, with some comedy before you get into the awards. That’s an Oscar tradition.”

Lazy loaded image

A-list presenters carried some of the heavy lift normally handled by a host. Among them: James Corden and Rebel Wilson, dressed like their characters from “Cats” — in a bit of a swipe at that film’s disappointing results. Mills said Corden came up with the idea and recruited Wilson to play along.

“I thought that was so inspired and you love somebody really making fun of themselves when they’ve been in something that wasn’t quite as successful as people thought it was going to be,” he said.

New this year to the telecast, however: Moments featuring young up-and-comers like Beanie Feldstein, Kelly Marie Tran, Anthony Ramos, Utkarsh Ambudkar and George MacKay, who were tasked with introducing bigger-name awards presenters.

“Lynette and Stephanie were really about inclusion, which meant new Hollywood voices with old school Hollywood royalty,” Mills said.

At the end of the night, as the “Parasite” team were in the middle of giving their thanks for the best picture award, the stage went dark — and stars in the front row, including Tom Hanks, gestured to turn the lights back up. Mills, who was in the production truck, said director Glenn Weiss acted fast to let the winners keep talking.

“Give all the credit to Glenn Weiss,” he said. “He really knows how to read the room, and that’s why you don’t see anybody played off at the wrong time. You’re cognizant of the clock and you want things to keep moving, but it’s a real faux pas when somebody is trying to dedicate an award and then you start playing them off or you put the lights down. The best picture has now become a moment where everybody involved in the film comes up and are a part of it. So it’s always hard to know quite when it’s ending. It was such a great moment, seeing how invested everyone in that room was and watching Tom Hanks raising his arms. Glenn immediately knew, put the lights up and opened the mics to let them finish. That was such a real, organic moment, and that’s the best of live TV.”

Lazy loaded image

Speaking of live TV, there was the unexpected moment of presenter Ray Romano dropping an F-bomb on live TV. Romano and Sandra Oh were tasked with giving out the award for best makeup and hairstyling, and as part of their banter, Romano was supposed to make a joke about his “The Irishman” co-star Joe Pesci telling him to “get your ass out of my chair.” Oh would then chastize Romano by reminding him that “this isn’t Netflix.”

Except Romano didn’t say “ass” — he said “get the f— out of my chair,” which was bleeped by the ABC censors. On Monday, Romano told KROQ’s “Kevin in the Morning with Allie and Jensen” show that the f-bomb was pre-planned — and that he ran it by his agent and publicist to see how much trouble he’d get in. They told him to go for it.

Romano told KROQ that he thought the “this isn’t Netflix” reaction worked better if he actually said a not-safe-for-FCC swear word, and not something that wouldn’t be bleeped. He also warned Oh he was going to make a split-second decision on whether to use the f-bomb, depending on the reaction to his first joke (when he introduced himself as Charlize Theron).

“I figured if the first line didn’t get a laugh, then I shouldn’t push it,” Romano said. “I’m trying to hard with the F-bomb. [But] the first line got a laugh.” Romano said no one from ABC called him on it afterward. “They’re so busy, probably ushering Elton John somewhere. No one even heard it, probably.”

Meanwhile, although this year’s Oscars made history, with the “Parasite” sweep making for a tremendous storyline, the ratings were disappointing — sinking 20% from last year.

“It’s difficult and obviously it’s disappointing, and when they’re down you always feel like someone just threw cold water in your face,” Mills said. “It’s also hard not to get caught up in how much everybody loved this, and how historical these Oscars were, and you have to take them both into context. You have to look at everything and see what we can do to stem the tide beyond the things that are out of our control — like people are watching TV in different ways and they’re streaming. You also have to say, OK, a year from now people are going to forget the numbers but remember he fact that ‘Parasite’ pulled off this historic win.”

“We’ve already talked about next year’s show, what are we going to look at, and let’s look at the research and see if there are people who are lapsed viewers, and how do we get them back?” Mills added. “You want to enjoy what this show achieved last night, too. Look at the ratings, try to make it better, but also be proud of what was accomplished last night.”

Could that mean a return to a host next year? “I don’t think anyone specifically said this year or last year, ‘Let’s not do a host.’ I think next year nobody’s saying, there has to be a host. I think everyone wants to get the right host.”

ABC will have an opportunity later this year to revisit how to handle awards telecasts in this fragmented age, as it’s their turn to broadcast the Emmys. As for the Oscars, “now we’ve got 55 weeks until the next one,” Mills said.