modifed the sampler