initial code using parallelReduce