update distance calculation