fixing calculation errors with denominator
bug fixes