improve variable handling

Correct handling of $A vs. $A_POS where previously $A_POS got replaced as $A keeping _POS