changed Undo and check logic