fixed bug in quadratic calculation