refactored code to move to classes in search call