clean up code
Refactor: Using JSON and transforming it to xml at the end instead of starting out with XML.