Refactoring search controller