pretty good search algorithm