refactor search