Converted distanced in findNearestGate to a double