Move search functionality to Function and control using checkbox