prototype of xml output | a lot of refactoring