change the if else into a ternary operator