Some refactoring in search controller