added handler for curve fitting error, try again with smaller degree