refactoring search inside api