Convert ternary operator to proper if...else structure