fixed when to allow undo and redo