Is there a way to express this all in one loop? Making a series of checkboxes.
Put check and unchecked in a parent layer called "checkbox" and then put the event on that parent. Do a switch instant on checked so it's offset from unchecked and then just call states.next on both from the parent layer
On a second though, this might not answer your question. Can you share your file?
here's a pretty compact approach. the checked layers are subLayers of the unchecked ones and renamed to just "checked".
Im sure you can simplify further by programmatically pushing them into the array