Added handling of http errors ( such as non 200 error codes)