refactored the search part of the app