improved error handling and removed XML from response - now the response is json
completed cleaning up the error handling