fixed logic in detecting invalid quadratic