refactoring search related stuffs