Fixed bug when curve_fit fails.