finish the function of searching