Switch the computation from integer to double. This fixes travel time issues. Length_mid is decimal and it's rounded down to zero upon casting to an int.