Finished merging the serial and parallel versions