added parallelization, must now be compiled with flag -fopenmp