Refactored Distances Code and Added Example