fixed problem of erasing iterator that then tries to iterate