Fixed small error in algorithm.