Added response code check and headers