refactor SearchController and SearchHistory