Refactor searching