fixing calculation errors with denominator