added check on null and valid for RPC response