removed some pointless steps in distance calc