Added assertion to undo and redo methods