improved handling of http error statuses. Checking the returned data before moving forward.