place iterator.remove() inside the for. The refactoring makes it confusing to read