You can use variables if you need, just set them to correct values before adding to the list. You mean something like this?
The code from your latest screenshot will not work, because the function is called on start of layout, when true=false. (Please don't name variables like this, it's really confusing)