bugfix on variable replacement