bug fixed
resample reimplemented