Small refactoring in search directive