cleanup of code, http error code on api error