history management corrected in the case of a addhistory after an undo