iterative grid search