Adding undo functionality.