replace if/else with ternary operator