Refactored a loop to Parallel.For