ACT-1887: fix to prevent duplicate inserting of variables is some cases