refactoring of how search gets triggered