added handling of http codes