Added Resample function