Fixing the distance method