Move remaining parallelism check out of the outer/inner loops and into the parallel_check() function.