Knack - adding and removing specific User Roles

I have a list of User Roles in Knack but I need to remove a specific role if the role is selected and add a specific role is the role is not selected.

I have the two following but how can the logic be combined:

{{if(!contains(10.field_235_raw; "profile_366"); add(10.field_235_raw; "profile_366"); 10.field_235_raw)}}

{{if(contains(10.field_235_raw; "profile_367"); remove(10.field_235_raw; "profile_367"); 10.field_235_raw)}}