Fixed undo bug