refactoring search controller