fixed UB arisiong out of reference-invalidation