handling http error more effieciently