The mystery at the center of Detective Pikachu takes protagonist Tim and his buddy Pikachu all Ryme City as the pair try to find out what happened to Harry Goodman, Tim’s detective father. Of course, things escalate as they get nearer to the truth, with sinister figures (and their Pokemon) try to stop Tim and Pikachu from solving the case. Be warned: We’re about to explain, as well as spoil, the ending of Detective Pikachu, so read on at your own risk!

Things get a little confusing as the movie progresses, though. Tim and Pikachu, along with journalist Lucy and her partner Psyduck, discover a strange laboratory. It turns out that Howard Clifford, the founder of Ryme City, had the powerful psychic Pokemon Mewtwo captured and studied in that lab in order to discover the secrets of Pokemon evolution. Through their work on Mewtwo, the scientists discovered two things: the strange R chemical that’s key to the mystery, and a Mewtwo power that nobody previously knew about.

At the climax of the movie, Tim learns the truth about what’s happening: Howard is obsessed with Pokemon evolution and wants to find a way for humans to evolve into better versions of themselves. He intends to beat his degenerative illness (and to become the ultimate Pokemon fan) by using the newly discovered Mewtwo power to transfer his spirit into a Pokemon’s body. Yup, his plan is to take over the body of a cartoon animal with magic powers.

Howard doesn’t just plan to Pokemon himself, though. He also transfers everyone else’s spirit into their Pokemon, too. Why would he want to do that? That’s a very good question. Anyway, let’s press on.

As Howard explains it to Tim, there’s an obstacle to transferring the humans into their Pokemon–it can only happen when the Pokemon are in a wild, crazed state. That’s the real reason for the R chemical: R causes Pokemon to lose control of themselves, and in the process, to lose their sentience. When the R chemical freaks Pokemon out, it leaves them open for the spirit transfer.

The thing is, Mewtwo doesn’t really want to cooperate with this plan. It escaped from the lab at the start of the movie, with the help of Harry Goodman and his Pikachu. As the detective pair fled the lab, Howard sent his genetically modified Greninja Pokemon to attack Harry, causing his crashed his car and left him for dead. Mewtwo, grateful for Harry and Pikachu’s assistance in escaping, came to their aid, and Pikachu volunteered to let Harry’s spirit take over his body, in order to save Harry’s life after the crash.

That’s why Detective Pikachu can talk throughout the movie. (Why he can only talk to Tim is maybe some kind of father-son bond thing? Let’s just go with it.) It also explains Detective Pikachu’s amnesia and why he can’t remember how to use his Pikachu powers. All through the movie, Detective Pikachu is actually Harry, who can’t remember being human.

When Tim and Detective Pikachu find Mewtwo in the middle of the movie, they accidentally lead Howard (and Howard’s Ditto, posing as his son Roger) straight to the powerful psychic Pokemon. Howard recaptures Mewtwo and uses a special helmet on the Pokemon that allows him to take control of Mewtwo with his mind. Then, Howard dispenses the R chemical that he’s hidden in the Pokemon parade balloons, zapping all the Pokemon in the city and make them wild. Finally, he uses Mewtwo’s powers to transfer all the humans’ spirits into their Pokemon.

Luckily, the R chemical doesn’t affect Detective Pikachu, because he already had Harry’s spirit inside him. That allows Detective Pikachu to fight Howard-as-Mewtwo and win. Detective Pikachu manages to get the helmet off Mewtwo, and that frees the Pokemon from Howard’s control.

Once the plot is uncovered and Mewtwo is back to normal, it uses its powers to undo everything Howard did, separating all the human spirits from the Pokemon and restoring everyone to normal–including Harry.

In the end, Howard Clifford is arrested for his plot to turn put an entire city of people into Pokemon bodies, Mewtwo gains his freedom, and Tim and Harry reconcile. Most everything is wrapped up, except for a few dangling threads, like what happened to those huge, genetically modified Torterra who could annihilate Ryme City with a fart, or those genetically modified Greninja who have repeatedly attempted to murder people on Howard’s orders? And where’s Mewtwo headed with the power to turn people into Pokemon? Could he zap the spirits of people he doesn’t like into anything else, like rocks or trees or lamps?

Maybe those are cases for Harry, Tim, and Pikachu to solve at some later point. Hopefully, before anybody is killed, accidentally or on purpose, or turned into furniture.

Detective Pikachu is in theaters now. Next, read our full Detective Pikachu review. Then check out how Ryan Reynolds originally wanted to play Pikachu–it could have turned out very different–and all the Pokemon Easter eggs, references, and inside jokes we spotted. We also have a video breakdown, a report from Detective Pikachu’s movie set, and the Pokemon Go tie-in event that’s happening this week.