refactoring of search controller