Refactor search_controller