add zero denominator check