fix invalid iterator in insert.