improved protection against infinite points (in case denominator of fit function gets negative)