new Bayes algorithm