changed parallel_for_each implementation to parallel_for