DWITE 2012-11 P5: Fixed algorithm.