cleanup search function