when using logical indexing e.g. counter1[counter2 > 5] the indexing is called at multiple locations in the code, e.g. when the indexing is only required as the name of the counter.
Here we need to carefully check if square brackets are present in the counter and possible encode them.