Combining grid search with nested cross-validation