#5 adding bayesian cost function