Fixed error in code causing concurrent modification exception