replaced List<Term> with Set<Term> in order to avoid duplicate Terms