Photo-Illustration: Maya Robinson/Vulture and Photo by Getty Images

Until recently, the ratings battle between NBC’s Jimmy Fallon and CBS’s Stephen Colbert wasn’t much of a battle at all. Week after week, for most of 2015 and all of 2016, Fallon’s Tonight Show would draw a bigger audience and better demographics than Colbert’s Late Show. But like so much else of late, that’s changed in 2017. While Fallon’s show still skews younger, Colbert has surged ahead of Fallon in overall audience, racking up five consecutive weekly victories. The Colbert streak began the week of President Trump’s inauguration, and that’s probably not a coincidence. But it’s also not the whole story. Late-night shows don’t turn on a dime, and audiences don’t shift allegiances on a whim. Making Colbert Great Again was a process, one which began long before the idea of a President Trump seemed realistic. After talking to our best industry sources, and studying recent public comments from some key Late Show players, we’ve identified five factors that set the stage for the Colbert comeback:

Colbert realized he needed to stop being a micromanager.

CBS execs and Colbert aren’t talking right now: They politely declined requests to be interviewed on the record for this story. But the network and the host himself have been very candid previously in admitting Colbert initially bit off more than he could chew when he made the jump from Comedy Central to Late Show. Colbert sweated every aspect of his new show’s production, including things not directly related to what ended up on air. That might be fine when you’re overseeing and starring in a four-nights-a-week half-hour cable show build around a fictional personality; in fact, given how intensely Colbert-centric The Colbert Report was, obsessing over details was probably essential. But as Colbert told The Hollywood Reporter last summer, he ended up making a lot of decisions best left to a showrunner — a powerful, nonwriting executive producer such as ones hired by David Letterman (Robert “Morty” Morton), Conan O’Brien (Jeff Ross), and Jay Leno (Debbie Vickers). “I thought I could do it, I thought it would be a natural transition to make,” Colbert told the magazine. “But that was a real revelation to go like, ‘No, if I want to do the show that I want to do and enjoy it at the same time, I have to have somebody else come in here.’” CBS chief Leslie Moonves, Colbert added, told him he was missing such a figure “two weeks in. And it took me to Christmas to go, ‘Oh, this is what he means.’”

Still, nothing major changed until last April. Following a poorly received live post–Super Bowl edition of Late Show, which TV critic (and Colbert fan) Brian Lowry called a “wasted opportunity,” and six months of decidedly meh (though hardly disastrous) Nielsen numbers, the Eye network announced it was moving CBS This Morning executive producer Chris Licht over to Late Show to act as a showrunner and provide, as Vulture described it at the time, “a new rudder” to a show that clearly needed to make some creative adjustments. Licht, however, was not imported to change the comedic tone of the show or serve as some sort of network nag. His job was to take responsibility for the mechanics of producing five (nearly) live hours of TV each week — which celebrity guest should appear first, when the show should cut to commercial, how to balance different kinds of segments. As Licht told the New York Times last fall, “Anything that doesn’t involve him thinking creatively and enjoying his performance — anything that gets in the way of that, I take.” Colbert, in turn, would finally be free to focus entirely on the funny.

The creative evolution begins.

By spring 2016, with Licht onboard, noticeable changes to Late Show — some of which had begun pre-Licht — started becoming evident. A regular cold open, smaller in scale but similar in style to what Saturday Night Live does each episode, was added to the top of the show. Intellectuals, authors, and Silicon Valley business leaders — key parts of early guest rosters — began popping up far less frequently. Behind the scenes, a quiet push was made to add more diversity to the Late Show staff. And over time, regular viewers could see that Colbert was clearly beginning to grow more comfortable in Letterman’s old chair. With fewer production demands to deal with, and more distance from his old Colbert Report character, Colbert the Host started to emerge. And just as CBS executives had hoped when they hired him, he turned out to be pretty good at the gig. “He found his voice again, and with authority,” says one veteran network executive intimately familiar with the late-night landscape. “And you know what else? He began to relax. His interviewing became better. He became a better listener. He became a new guy.”

Filmmaker Rob Burnett (The Fundamentals of Caring), a former head writer for Letterman’s Late Show who in 1996 also took on showrunning responsibilities, says it’s not at all surprising that Colbert needed time, and the ability to focus, in order to improve as host. While audiences who watched Letterman transition from Late Night to Late Show in 1993 may not have noticed it — early reviews were raves — Burnett says even Dave and his team had an adjustment period. “At the start of a show, as we experienced when we moved to CBS, you are finding what works and doesn’t work in a new space,” Burnett told Vulture via email. “It is very challenging to simultaneously build the machine and feed the machine.” Burnett said he’s also heard that Colbert “wanted his hands on everything at first” as he was starting Late Show. “That is understandable,” Burnett said, “but there are things that he can do that no one on Planet Earth can do. In my opinion, that’s where the very best use of his time lies.”

Colbert has also made it clear to interviewers that part of settling into his new job was realizing he didn’t need to completely remove all traces of the Colbert Report DNA from Late Show. In the months leading up to the CBS show’s September 2015 launch, much was made — by critics and Colbert — of the challenge he faced in going from playing a fictional character on Comedy Central to simply being himself. What got lost in that forced transformation, he admitted in the Times interview, was the understanding that Fake Colbert and Real Colbert are not completely distinct personalities. “It is all me,” Colbert told the Times. “Of course it’s me. I thought of the character. It’s my humor.” By the summer of last year, Colbert even started bringing back elements of the old show, albeit sparingly (perhaps to avoid any legal troubles from Comedy Central). If early Late Show Colbert was insistent on selling CBS viewers on a whole new host, mid-2016 Colbert was okay with offering fans the full range of his persona, even if some of it was “fictional.”

The convention pivot.

The creative adjustments made in the spring were put to the test later that summer. During the Republican and Democratic national conventions in late July, Late Show switched to a live format, allowing Colbert and his writers to serve up the most topical comedy and commentary possible. All of the changes made over the previous few months allowed Colbert and CBS to show off a Late Show which was tighter, funnier, and incredibly relevant. Colbert was particularly brutal in skewering Trump and the RNC, something that served to reconnect Colbert with the politically progressive viewers who had been his base on Colbert Report. It was also during these two weeks that Jon Stewart made his first-ever visit to Colbert’s live show and fictional Colbert popped up — timing that was surely not coincidental. If Colbert had previously worried too much about being “himself,” or coming off too much like his old persona, he was now comfortable enough to reunite the old gang.

Watch a supercut of Colbert’s best Trump burns:

The convention shows were a major success. Ratings ticked up, and critics mostly kvelled over the new-look Colbert. Several segments from the convention episodes went viral on YouTube, something the show had struggled to do previously. Perhaps most importantly, the narrative surrounding Late Show subtly started to shift. While rumors about CBS getting cold feet with Colbert appear to have been just that — rumors — media coverage of Late Show had started painting it as “struggling,” particularly after Emmy voters snubbed it in key categories. That shifted after the conventions.

The final four months of the bonkers 2016 campaign might as well have been genetically engineered for a politically minded comic figure such as Colbert, and Late Show did all it could to capitalize on the intense national interest in Clinton versus Trump. It once again went live after several debates, and on Election Night, CBS took the unusual step of letting Colbert do a live show on another network (sibling premium channel Showtime). Upbeat profiles of the show and its star began popping up in publications such as The Hollywood Reporter and the New York Times. Colbert was still far behind NBC’s The Tonight Show Starring Jimmy Fallon, but the seeds for progress on that front had been planted.

Fallon fades.

One of the key elements of the Colbert comeback has been something completely out of his control: Chief rival Jimmy Fallon has been bleeding viewers over the past year. As 2015 ended — and before the 2016 political season began in earnest — Fallon was drawing nearly 4 million viewers every week. On average, he was ahead of Colbert by nearly one million viewers. A year later, at the end of 2016, Fallon’s weekly audience had shrunk to 3.4 million; his lead over Colbert was down to around 500,000. And now? As of last week, Fallon is averaging 3.3 million viewers, barely 300,000 more than Colbert’s season-to-date average (3.043 million). Colbert has been showing modest year-to-year viewer gains most of the season, particularly last month, when his overall audience jumped 25 percent versus February 2016 to 3.6 million. But as TV by the Numbers’ Rick Porter noted earlier this month, what’s nearly as big of a story right now is how much Fallon has come back to earth. He’s losing ground more rapidly than Colbert is making it up, thus making it much easier for Colbert to roll up five consecutive weekly victories.

Liberal critics of Fallon no doubt have a theory as to what’s happened: His fawning interview of candidate Trump last fall turned off a huge swath of the electorate, and the late-night audience. This seems a bit far-fetched, particularly given Fallon was losing ground even before that interview and considering the fact that Colbert conducted his own softball interview with Trump (albeit one without hair-tousling). The real answer is probably a bit more complex, though still related to politics. Fallon’s show hasn’t suffered from any obvious decline in quality. But with so much of the country obsessed with politics and the fate of the free world, Fallon’s brand of fun and games — while still plenty popular — just feels less … relevant. As Moonves told attendees of the Deutsche Bank Media and Telecom Conference last week, with Trump in the White House, “People want to see social commentary at the end of the night. They don’t want to see fun and games.”

And then there’s Trump.

Trump’s win, and his January 20 inauguration, were likely the final factors in once more making Colbert competitive in the late-night ratings race. It’s hard not to make the connection: Having been stuck in second place since October 2015, Late Show moved ahead of The Tonight Show in overall audience during the first full week of the Trump administration, and it hasn’t surrendered said lead since. Blending pop psychology with Nielsen analysis is generally risky, and clearly not very scientific. It’s impossible to definitively link Trump with Colbert’s resurgence. As noted, Fallon has declined more than Colbert gained; NBC’s star has also remained comfortably in first place among the advertiser-coveted, adults-under-50 demographic. What’s more, most of Colbert’s weekly wins this year have come during weeks in which NBC’s biggest prime-time hit, The Voice, was on hiatus, thus depressing the network’s overall audience and possibly hurting Fallon a bit.

And yet, when The Voice began its new season two weeks ago, Colbert stayed on top, despite a noticeable uptick in Fallon’s ratings. Colbert’s margins of victory over Fallon have generally been pretty slim, though when DVR replays are tallied — yes, people tape late-night shows and watch later — Late Show’s been able to put a healthy distance between its main rival. In February’s same-day ratings, Colbert bested Fallon by just 157,000 viewers on average; once DVR replays were added, that lead tripled to 517,000. That’s a sign that, for now at least, audiences consider Colbert must-see TV (and, perhaps, that some of his older viewers simply aren’t going to stay up late to watch Colbert skewer Trump). It’s also part of a pattern popping up elsewhere in TV: Trump-related programming with a strong partisan edge is doing spectacularly well right now. MSNBC is thrashing CNN in overall audience during prime time, with its most high-profile Trump critic, Rachel Maddow, coming close to 3 million viewers on some nights — triple the audience she was pulling in before Trump announced his candidacy in 2015. Samantha Bee and Bill Maher have also been flirting with ratings records. And while Fox News’ year-to-year gains haven’t been as impressive — in part because it was starting from a bigger base — the top-rated, Trump-loving news channel has also been notching huge Nielsen numbers.

Even if it’s impossible to calculate just what percentage of Colbert’s gains (or Fallon’s losses) are tied to Trump, and the climate his election has created, it seems clear he was a significant factor in pushing Colbert over the top in recent weeks. Still, it would be unfair to Colbert, Licht, and their team to dismiss what’s been happening as an ephemeral ratings blip caused by current events. The changes Colbert and company began making nearly a year ago were essential in ensuring Late Show was fully prepared to step up when the Trump tsunami hit. Had the show been operating the way it was around the time of his poorly executed February 2016 Super Bowl show, it’s hard to imagine audiences responding the way they have recently. Plus, late-night shows rarely turn on a dime. Pop historians sometimes point to Hugh Grant’s infamous visit to Jay Leno’s The Tonight Show — “What the hell were you thinking?”— as the moment that pushed Leno ahead of Letterman in the ratings for good. In fact, Leno had been making changes and gaining ground for months before that iconic moment. The massive PR Leno’s interview generated surely helped, but Leno had already been laying the groundwork for his resurrection. Assuming Colbert continues his hot streak, the same will be true for Late Show 2017.

The biggest question in late night is, of course, how long Colbert can keep beating Fallon — and how much it matters if it doesn’t. The same hyperfocus on Trump and politics that helped Late Show leap ahead could turn to Trump fatigue if audiences simply grow sick of hearing about the president’s misadventures. (There’s also the chance Trump could suddenly become boring, but … yeah, no, that’s not going to happen.) On the other hand, liberal anger at the Iraq War and the Bush administration’s stumbles remained fierce for years in the 2000s, so it’s also quite possible Trump rage could fuel Late Show ratings for years. Colbert and his team also aren’t dumb: Even now, regular viewers of the show can see Colbert pulling back ever so slightly on D.C. humor on the (few) days where the news doesn’t warrant it. Late Show has not turned into an hour-long version of Colbert Report. Remember, this is a man who managed to stay in character for nearly a decade. Colbert knows a thing or two about pacing himself.

But should the ratings race tighten again — not unlikely, given NBC’s overall strong prime-time performance of late — CBS execs are unlikely to panic. Even when Late Show was getting whooped in the ratings, Eye execs maintained the network was making more money than in past years because Colbert’s show is far cheaper to produce than Letterman’s decades-old show, which had a much bigger production budget (and because it was owned by Letterman, there was less financial upside for CBS). Plus, Colbert has clearly found his voice and connected to a core audience, two of the hardest things to accomplish in late night. Letterman’s Late Show was No. 2 for most of its run, but it lasted more than 20 years and went out in a blaze of glory. As long as Colbert keeps producing a show that’s relevant, well-reviewed, and doesn’t completely tank in the ratings, he stands a good chance of still being on CBS when Trump leaves the White House.