Improved the code for Calculating the polynomial coefficients