fix undo bug for clear