improve performance of MergeVars