Added some lines from joblib to do the grid loop in parallel