updated to avoid concurrent modification