Implement resampling.