Added http error handling