Multi-Select Checkboxes question

I’m using a list of checkboxes as a multi-select function for users to choose from multiple items, although those items are not a Dynamic Repeating Group, they still reflect items from a type, so when a user selects an item, it adds/removes this item to a Custom State which keeps a list of that type.

The way i did it is by telling the Custom State whenever this checkbox value changes to add /remove item which its name = to the checkboxes is checked formatted as text value, which i named as the checkbox lable and name in database.

(i didnt use an RG for various reasons)

  1. But how can i make an item be added/removed when the checkbox value changes automatically through a condition.

  2. And what if i want the default state of the checkbox to be reflected in the Custom State Automatically?