Completed minimum Distance Algorithm - 13 November 2014