simplify ternary expression