Combine the 'what to undo' queries into a one pass operation