xml stuff, refactoring