Fixed problem with resampling