Fixed out of bounds error for gridsearch minimizer.