solved quadratic case