Move search logic to helper