refactored the return results for search method