refactor searching