fixed formula for distance