Shake it off: That was the message of one New Hampshire graduating class at last week's commencement ceremony.

Valedictorian Colin Yost gave a speech about embracing one’s inner nerd at his Portsmouth High School graduation, ending his remarks with, “All you have to do is shake it off.”

Taylor Swift’s pop hit “Shake It Off” came blaring over the loudspeakers as Yost started to dance. To everyone’s surprise, all 230 of his class members joined in.

VIDEO: Taylor Swift Song Immediately Makes Baby Stop Crying

Students had been working on the choreographed flash mob ahead of graduation, unbeknownst to their parents.

Yost and his friends made an instructional video, which they shared with the entire class on YouTube. The administration also let them use five graduation rehearsals to practice the dance.

Watch the fun flash mob above.

Fortune Names Taylor Swift – Not Obama – One of World's Greatest Leaders

Cop's Hilarious 'Shake It Off' Dance Gets Taylor Swift's Attention