Rewrite using a ternary