added Eric's robit gibbs code
switched to using ifelse in conditional