var2xml refactoring