It’s not every day that a president manages to outwit the opposition in front of a live audience. But that’s exactly what President Joe Biden did during his State of the Union address on Tuesday night. In a brilliant display of mental dexterity, Biden managed to box in Republicans on Social Security and Medicare and secure a policy victory for the programs.

In a move that took even his allies by surprise, Biden went off script and cleverly called out the GOP for wanting to let Social Security and Medicare expire after five years if Congress doesn’t pass a new law. As Republicans jeered, Biden accepted their response as an agreement to keep the programs intact. “As we all apparently agree,” he said with a grin, “Social Security and Medicare is off the books now.”

Biden’s move was a win-win for both parties. To whatever extent he protected the entitlement programs, he also made it harder for Republicans to campaign on the idea that they are bent on destroying them. But more importantly, Biden demonstrated that he is still mentally sharp and able to think on his feet even at his age.

The exchange also highlighted a key point about the upcoming election: that themes from the State of the Union may help frame the coming months and the next election. Biden’s quick thinking gave the GOP an unexpected gift by claiming a policy victory on the entitlement programs and offering them a chance to publicly stand in support of Social Security and Medicare.

It’s clear that Biden’s performance during the State of the Union was a testament to his mental agility and quick wit. As he gears up to run for re-election, Biden has shown that he is still a formidable opponent who can outsmart his opponents in a heartbeat.