P.J enters a contest to win the title of Master Detective based on the Casey Calloway detective books. He dresses up as character Casey Calloway. Keith comes along to meet the author of the book, Polly Hoshimoto. When they arrive at Polly's house they run into Francine who acts as rival Lilah Lavender who's good at cheating. Inside, Polly gives them a first clue to find a helping hand but Francine can cheat just like her character. Later at the diner, The Electric Company help P.J. with the clues that include matrix codes. Lisa pretends to be Ginger Snap Gonzalez who assists Casey. They go to a house to receive another clue which says 'Where did Casey eat noodles?' They go to P.J.'s house where the answer is on a cover of another book. Then they find another clue on the back of Polly's book which says 'Where did Casey get fined?' Lisa's knows it's the library so they head out. Meanwhile, Francine has an idea she can make her own code just like her character. She goes to the library to receive another code and then sets up a fake one before the gang arrives. P.J. and The Electric Company take the fake code that sends them back to the library where they receive another clue which says Casey has lost. They know Francine is behind it. They head back to the library where P.J. peels off the fake code and use the real one which tells them about Casey's corniest hiding place. P.J. knows Casey hid in a cornfield in Arkansas, but had an answer. He uses his computer and see a cornfield that looks like a code. They uncover a final clue which says 'In order to be a master detective, you have to have the last word,. Lisa says it's the last word of the three titles which turns out to be 'One Smart Cookie'. And that cookie is Ginger Snap Gonzalez. Later, Polly gives P.J. the plaque of Master Detective after winning the contest. Poorly, Francine's clue has her lost in a cornfield somewhere in Arkansas.