modified code for  and  to handle coefficients that go to zero but then escape