copy collections to avoid ConcurrentModificationException