fix an iterating bug: erase during iterating