Used outer loop for omp parallelization