fixing up search.  consolidating code