better handling of status codes