refactor search command