copy the hashset before iterating