First working version of the MCMC resampler