refactoring bayesian.go