The longer a mainstream musician lasts, the higher the likelihood that their late period output is going to be trash. It’s just numbers. Few artists are capable of making one great album, let alone replicating that unique kind of success over the course of decades. Everyone’s got a stopping point where every successive release is just an excuse not to have to tour on old hits. For Madonna, most critics agree that last stand was 2005’s Confessions on a Dance Floor. But they’re wrong. It’s 2008’s Hard Candy.

Now, Hard Candy is not a perfect album. Upon initial release, it seemed like Madonna, an artist exalted for her dedication to innovation, was giving up her need for relentless reinvention to play third wheel in the ongoing Timbaland/Justin Timberlake bromance that had taken pop by storm on 2007’s FutureSex/LoveSounds. This was nowhere more evident than “4 Minutes,” the JT guesting lead single on which the album was promoted. For whatever reason, all parties involved thought it was a good idea to make a track that closely resembled the theme song to the hit Nickelodeon game show “Global GUTS,” so it’s not a shocker people saw the album as a cheap ploy for relevance.

That’s not to say Timbaland’s presence is completely superfluous. Closing tracks “Devil Wouldn’t Recognize You” and “Voices” both sound like the oddball middle ground between Timberlake’s “Cry Me a River” and Madonna’s own “Frozen”, but they present a moodier tone that makes a great comedown from the sugar rush dance party of the earlier tracks. “Miles Away” is also a standout, exploring the pains of long distance romance from a superstar’s perspective over a plaintive, southern-fried instrumental reminiscent of Timbo’s work on Bubba Sparxxx’s Deliverance.

But Hard Candy has more in common with Timberlake’s debut solo effort than the sci-fi sexcapades of his sophomore follow-up. See, Timbaland’s involvement only amounts to five of the 12 songs on the album, while the rest are attributed to the Neptunes, specifically with songwriting and production from Pharrell Williams. Just like Justified, Hard Candy features the two Virginia based hitmakers battling for chart topping supremacy as they have for countless other artists. Hearing the two go beat for beat on a rap or R&B album is always a blast, but the real spectacle here is how Madonna herself plays within these soundscapes.

The PR tried to spin Madonna working with two household name producers as her getting back in touch with her dance pop roots after years of working with lesser known talent behind the boards, but that’s not exactly true. What makes the album so special is how well she and Pharrell work together, and not because he’s channeling the specter of her earlier classics. This is an aged, wiser Madonna marrying personal lyricism to some truly timeless production. The Timbo-produced cuts are hit or miss because they sound like FutureSex cutting room floor fodder repurposed for a new artist. They clumsily adorn the outside of a house Pharrell had already built with carpenter-like songcraft.

Tracks like “Give It to Me” are easily identifiable as Neptunes productions, but this isn’t Pharrell leasing out his signature sound. He’s channeling a crystalline distillation of disco, electrofunk and the influence of future “Get Lucky” collaborator Nile Rodgers (perhaps the last great household name Madonna ever partnered with). Madonna sounds brand new on these tracks, but there’s an introspection at play, all leveraged against years of self-mythologizing from one of the most outsized personality in pop music.

This is clearest on the LP’s two finest songs, twin epics “She’s Not Me” and “Beat Goes On.” On the former, Madonna spins a yarn to an ex about how inferior his new lover is. The song can be read as a cocksure declaration from a jilted former flame, but in the context of the album and its release, it feels like an unsteady queen trying to assert her place in a changing pop landscape. The song goes on for six minutes, buoyed by Wendy Melvoin’s nimble guitar work and Pharrell’s driving beat, but it’s not hard to imagine Madonna ruefully singing these lyrics to herself while watching a Lady Gaga video.

Along these lines, “Beat Goes On” follows up with Madonna psyching herself back up and accepting her place in the pantheon. It’s a pure, unadulterated dance epic with a catchy hook, undulating synths and a completely unnecessary but totally welcome guest verse from Kanye West. Back to back, these would have made for one epic music video, painting the conflict of an icon in the twilight of her career making on last stand before riding the wave and coming to grips with whatever the future holds.

Unfortunately, all of this album’s A-sides were treated like also-rans, so few listeners really wanted it to give it the chance to shine. But it’s still out there and in the last 10 years, Madonna hasn’t made anything close to matching it. Everything comes to an end sometime. This is far from the worst act to bow out on.