using cached distances between points