Replace a condition (if else) with ternary operator