refactoring search controller to close #1591