fixing some bugs in gibbs sampling