modified the parallelization code for code reuse