Consolidate search code