move resample function to Profile for speed-up