proper synchronization to prevent ConcurrentModificationException