rename error variable for resampling
refactor sampling module