refactored code into another .c files that deals with the search feature