finiched the basic function for search
almost finished discover function