As soon as the world learned of Prince’s untimely death, heartfelt tributes started pouring in. Lin-Manuel Miranda – like many others – took to Twitter to quote the pop icon before admitting that he felt gutted.

Miranda said blasting Prince’s music saved his day, and he hoped it would do the same for others. That’s why he and the rest of the Hamilton cast closed out Thursday’s show the only way that seemed fit: by dancing to Prince’s “Let’s Go Crazy.” Though it seemed like a pretty spontaneous performance, Miranda revealed that a lot of work went into it. “[Alex Lacamoire] SPENT THE DAY orchestrating the chart,” he said about the show’s musical director on Twitter. “Incredible.”

Check it out above, or see the performance from other angles below: