refactoring searching + tests