There are several losers in the extramarital affair that brought down Alabama Gov. Robert Bentley, starting with the man himself, who ended up resigning on Monday and pleading guilty to two misdemeanor crimes. There’s also his paramour, Rebekah Mason, who resigned from her job when news of the affair first broke last year. The entire state of Alabama lost its governor and took another hit to its already-tattered reputation in the same month a hit podcast named one of its municipalities “Shit Town.” Poor Robert, poor Rebekah, poor Alabama.

But, to the extent that sex scandals that lead to ethics violations and campaign-finance missteps can have winners, the Alabama fiasco has a big one: Dianne Bentley, Robert’s ex-wife. This hero was instrumental to the state legislature’s investigation and Robert’s eventual downfall, giving her the upper hand in a familiar scenario that usually relegates politicians’ scorned spouses to the role of the “Good Wife” or hurt victim.

For several months, Dianne secretly documented her then-husband’s affair, informing the bulk of the House Judiciary Committee’s impeachment investigation. She suspected something was up in September 2013, when she noticed that Mason and her husband were texting at strange hours. In February 2014, at a dinner in Washington, D.C., she saw Robert text Mason from across the table, “I can’t take my eyes off of you.” Dianne didn’t flip over the table, hit Robert smack in the bald spot with her wine glass, and go straight to the press. Instead, she began collecting evidence.

The best evidence came from Robert’s state-issued iPhone, which, as luck would have it (for Dianne), was synced with the state-issued iPad he gave his wife. The 74-year-old governor didn’t realize that his secret texts with his 30-years-younger lover would show up on both devices. And Dianne took photos. Oh, did she take photos! She documented the illicit couple’s pet names, “sweetheart” and “sweet baby” and “sweet thing.” She documented the moments when Mason wrote sweet southern-Christian nothings to the governor, when she texted him “Bless our hearts. And other parts,” and, perhaps when the investigation began, “Your purpose. Your mission. Your ministry. Your service is being stolen from you.” Dianne documented Robert’s habit of texting his lover two heart-eyed smiley emojis in a row (“I’m so in love with you 😍😍”; “I’m thinking of you now 😍😍.”) She took a full-screen photo of the poem of sorts Robert wrote Mason, each sentence its own text message: “So sweet. / So loving. / So soft. / So gentle. / So kind. / So supportive of me.” The texts were gross, on her very own iPad’s screen, and the key to her cheating, law-breaking schmuck of a husband’s undoing. So, even though reading them must have been beyond hurtful and infuriating, Dianne kept them.

Dianne also managed to pull off some top-quality spy moves in her private inquiry into her husband’s dishonor. She once left a running audio recorder in her purse, then left her purse in a room with Robert and told him she was going out for a walk. Sure enough, once she left, he started talking on the phone about putting his hands on Mason’s breasts and loving her “so much” it worried him. Robert’s attempts to get rid of Dianne’s recordings led him to threaten staff members, misuse funds, and commit other such transgressions that led to his impeachment. Oops!

As part of his plea deal, Robert had to promise that he will never hold public office again, a gift Dianne has bestowed on all Alabama’s inhabitants through her dogged record-keeping. She turned her misfortune of having married an amoral moralizer with the world’s least creative sext game into the blessing of removing a liar from public office for good. May the gods bless her in turn with a lucrative late-life career as a private investigator.