Adding method to compute distances from A to B