Transform if into trinary operator