Control being replaced by another one as long as it is not in focus

Hi, in my Notes transmittor I have a lot of pages where controls 1-16 and 19-34 are controls for midi channels 1 - 16. I want to change their colors using the first 16 on/off values on the first page, with a function called applyColor(value,channel). When value = 0, it turns the other control’s color in red else it turns it in white (for channels 1-4 or 9-12) or blue (channels 5-9 or 13-16).
All this works, but the codes does something unwanted: it also changes the controls 19-34 on the first page in type , color and value!

  • When the function is called with value 0, it turns the corresponding control that is 18 controls further down on page 1 also in red and in a on/off control in the off state with the name inherited from the valueObject the function was called from

  • When the function is called with value 1, it turns the corresponding control that is 18 controls further down on page 1 in corresponding white/blue and in a on/off control in the off state.

  • When I move the focus onto the changed controls, they revert back to the types and colors they are supposed to be.

  • If the weird control receives a different value from elsewhere, it also reverts back to the type and color it issupposed to be.

What causes this temporary identity theft?
Here’s the function I use. If you can’t reproduce the effect, tell me how to get the preset and/or code to you.

function applyColor (value,channel)
local color = BLUE
if value ==0 then
color =RED
elseif math.floor((channel-1)/4) == 0 or math.floor((channel-1)/4) == 2 then
color = WHITE
end
controls.get ( 36+channel):setColor (color)
controls.get ( 72+channel):setColor (color)
controls.get ( 90+channel):setColor (color)
controls.get (144+channel):setColor (color)
controls.get (216+channel):setColor (color)
controls.get (234+channel):setColor (color)
controls.get (252+channel):setColor (color)
controls.get (270+channel):setColor (color)
controls.get (288+channel):setColor (color)
controls.get (306+channel):setColor (color)
controls.get (324+channel):setColor (color)
end