Check for duplicates in nominator and denominator to avoid dividing by zero.