fixed distance calculation issues