some improvements at undo function