New resample algorithm