Take distance into account