Cast to double since we return a double.
Forgot to initialize field optimization_distance2.