added grid search support