added an algorithm to mimic BP update