added resample and reverse functions