Used long polynomials instead of loops