replaced iterators to eliminate concurrent modification error