Justin Lin gets it right.

There is a spirit of Star Trek that none of the reboot movies have captured. The first film was a blast, and the reimagining of the characters was fun, if shallow. The second film thought it was being Star Trek-y by tackling modern day political issues, but it came from a cynical position that Gene Roddenberry would never have sanctioned. That film truly undermined the characters, robbing them of both their essential essences and even the fun that the 2009 movie had granted them. Yes, there was new Star Trek in theaters but it felt like someone had messed with the ingredients of my favorite dessert - it certainly looked like the dish I love, and its taste was reminiscent, but there was something deeply off about the recipe.

Enter Star Trek Beyond, which is almost a miracle. Ignoring the entire last film, Beyond takes the fun characters of the 2009 Trek and imbues them with the soul of the original series, creating versions of the Enterprise crew who feel modern but also true to the vision of the 60s. These are smart, capable people, the best crew in the fleet, and they have nothing but love and respect for each other. They trust one another, they expect the best from one another and they give their best in return. They meet every obstacle with hope and ingenuity, and they use their brains more often than their phasers.

Co-writers Simon Pegg and Doug Jung injected that classic Trek feel back into the characters, but it was director Justin Lin who made all of that work within a modern blockbuster context. Make no mistake, Star Trek Beyond is a modern movie, but Lin understands that there’s a difference between an action movie and an adventure movie (and Trek is, after all, about the human adventure) and he stays on the correct side of that line. There’s a lot of physics-defying craziness going on, but it all thrills. And it’s on the right side of violence - when Kirk needs to cause a diversion to facilitate a jail break he does it by riding a motorcycle around, drawing the fire of alien guards, not by blowing something up or killing somebody. That may seem like a small thing to you, but it made me so happy here - violence is a last resort.

The film opens three years into the Enterprise’s five year mission. Captain Kirk is adrift, his time in deep space leaving him unsure about his future and his goals. He joined Starfleet on a dare, as he put it, but now wonders if that’s motivation enough, and he’s getting interested in a desk job. Meanwhile Spock finds himself feeling torn between his worlds; coming to believe his duty is to the Vulcan race he intends to leave Uhura and go father a whole bunch of baby Vulcans. But their existential crises are interrupted when a rescue mission turns out to be an ambush and the Enterprise is destroyed, the crew is separated on an alien planet and they have to deal with an aggressive enemy who has a mysterious grudge against the United Federation of Planets.

By splitting up the crew Pegg and Jung’s script allows the reboots to finally drill down on the character relationships. Somehow we have made it this far into the reboot without Spock and Bones having any great scenes, and Star Trek Beyond truly makes up for it. The duo bicker and support each other through their own adventure, with Bones being forced to care for a seriously wounded Spock. Zachary Quinto and Karl Urban have always been standouts in this cast, making these iconic characters their own while still homaging what came before, and in Beyond they’re at their best. Their chemistry is delightful, and their story feels like a season two TOS episode that should have existed.

Chris Pine is teamed with the late Anton Yelchin, and that storyline gives Kirk some smarts and depth he has badly needed for a while. There is still the brashness that defines the nuKirk, but it’s been tempered with both leadership and logic. He’s smart enough to see double crosses coming and lay traps for his enemies, but he’s brash enough that those traps often involve falling great distances or manic chases. Spock and Bones had been pretty great in all the films to date, but Kirk has been lacking, never quite having the patrician authority that William Shatner brought to the role. Pine finally has it here, and setting him against the younger Chekov makes sense, as it highlights the father role Kirk has in the ensemble. Sadly Yelchin has very little to do in this, his final Trek; I couldn’t tell if the role was underwritten or if he was trimmed due to sensitivity about his recent passing. The film does end with a stirring “For Anton” title card.

Meanwhile Scotty is off having his own adventure with the newbie, Sofia Boutella as Jaylah. She’s an alien who has escaped the clutches of villain Krall (more on him in a second) and has taken up a solitary life in hiding. Her storyline illuminates the film’s main theme, that in unity we find strength (which Scotty illustrates by telling a story about how one stick breaks easily but a bundle is strong - the primary image of fascism! Wrong example, Scotty!), and Jaylah brings a great attitude and action chops to the ensemble. Sadly Boutella is hidden under layers of white makeup but she’s such an excellent physical actress that she’s still able to get across so much with just a slouching hip.

The rest of the crew are stuck with Krall, played by Idris Elba. Krall commands a drone fleet and he sucks the energy out of captives to keep himself young and vital; he’s searching for an ancient artifact that the Enterprise just so happens to have. His goal: bring chaos to the Federation because he thinks that hundreds of years of peace have made humanity weak. Strength comes through conflict, he believes, and the differing views of the source of strength create a very Trek philosophical debate at the center of the action.

Krall is the film’s weakest spot; while he works on paper there’s just something half-sketched about his storyline that probably comes from the film’s accelerated development phase (they kicked out the original director and rewrote the whole movie with like six months to go before shooting). Elba is good, and he’s actually acting under tons of make-up for a reason (yes, there’s a reveal about Krall, and I think it truly, fully works), but he’s just not quite up to snuff. The film feels about one draft away from making Krall a great villain, and so in the end he’s merely serviceable. Also, his end is… fine, but there was a more Trek way to go about wrapping up his story that perhaps, one day, I’ll write about. If he had finished up with a Trek-ier finale, I think Beyond would have ascended to a whole other level of greatness.

But the film is still great; it’s the perfect example of how you can make a Trek film that has the DNA that fans love while still servicing the needs of the modern blockbuster audience. Hardcore fans may balk at some of the Enterprise’s more significant aerial maneuvers, but I’m willing to forgive that stuff because it’s so thrilling; Lin knows how to stage adventure action in a way that is exciting and fun and lets you kind of ignore the fact that physics are being defiled at an alarming rate. When the crew has to jumpstart an old Federation ship they find on the planet (part of a surprising series of nods to Star Trek: Enterprise, the only Trek show to remain fully in canon in the reboot universe) by dropping it off a cliff you know that it’s dumb, but it’s the right kind of dumb, the kind of dumb that Lin brought to the Fast and the Furious films.

That dumb is in service of theme and character, which is why I’m so willing to just smile along with it. I moaned when he got hired, but the Fast films actually proved that Lin got one of the fundamental aspects of Trek - the ensemble. He created a family out of characters there, and he’s able to reclaim the bridge crew dynamic in Beyond. What’s more, he folds that into the rebootverse nicely; the third act brings back Sabotage by the Beastie Boys in a way that, again, might irritate purists but that I felt was not only a great nod to the first movie, it’s a great way of bringing a uniquely Trek solution to a combat situation - while still feeling quite modern. That moment is the perfect summation of how well this movie works.

There’s no doubt that Beyond is the best of the reboot movies; it takes the energy that JJ Abrams inserted into the franchise and harnesses it for good, not for sub-Star Wars, Earth-bound nonsense. The movie loves the characters, and it features a moment near the end, an homage to the original crew, that made me cry. There’s respect here for what came before, but at the same time there’s a happy, forward looking desire to chart new paths. It only took three movies, but finally this well-cast crew has been giving recognizable versions of their characters to play, and it works perfectly.

If the Trek movie franchise flames out here (as this weekend’s box office indicates it might), at least it ends on a high note, on a movie where the stakes are philosophical in nature, on a movie that respects the history of the franchise while doing its own thing, on a movie that is filled with heart and love and hope. The sad part: it ends on the movie that proves you can make a true Star Trek movie in a blockbuster climate. What JJ couldn’t do, Justin accomplished, and I wish he had a chance to do it again.