Added resample function.