refactor search controller