Make sure you're still within the 24-hour window from when you purchased the first flight.
Book the new flight at the cheaper rate before you do anything else. This ensures you lock in this new, better price (it could go up in minutes).
Once you’ve booked the new flight, cancel the old one.
The reason you should book the new flight before you cancel the old is simple. If you cancel the old flight first, and then miss snagging the new flight at a great price, you’re out of luck and left with no ticket.
On the other hand, if you book the new flight first but then take too long and miss the 24-hour window to cancel the first one, you can just cancel the new one, keep the first one, and you're no worse off than you were in the beginning.