redundancy changes, preemptive error catching

removed some redundancy in polynomialRegression.

calculating polynomialRegression before checking for errors is now
fixed.