Account for NaN Threshold
Fixed divide by zero error