added proper error handling, fixed locationType in response