Changed error-triggering conditions to allow small roundoff errors