refactoring near complete code, next XML