improved performance by using parallel.foreach