small fix in resample2 function