Refactored openMP parallelization in order to improve performance