EDIT: I think that it’s not picking up the $1 as the operand. I tried storing it in a variable, then trying the assignment but it seems that has no effect. EDIT 2: provided a minimal reproducible script as requested. The error generating part of the code is the following: the rest of the function’s code will be attached below.