improving MCMC function