fix bug in first undo