extract the ternary operator out of the if condition