got the distance functionality working