cleanup search code