added some error checking but JSON response from API is not well formed