unary and pairwise term implementation