checking for response before using status code