bugfix
refactored distance methods out