Parallelizing the optimization problem