Added beginning of error handling (e.g. status codes)