pseudocode for gridsearch