modified to add some api calls and xml