Refactored task parallelism to Parallel.invoke