added feature for random resample