Now passing the function that does the fitting into the resampling code.