Added conditional to not divide by zero if term not present.