better ternary and clean