Avoiding concurrent modification exception