refactoring xml parsing