New distance calculation