next refactoring search loop