simplify ternary operation