Separate calculating distance functionality to a function
Merge pull request #2 from peecky/master

Overridable distance function