improve savehistory logic, ref #135