I don’t know what to tell you. This code works. I really don’t understand the issue and your screencasts doesn’t help to understand. In console I see you have the correct output, but you never show how you click the checkbox and what happens to layers
Sorry, but I don’t think I can help you any further