Added undo/redo for page swapping