simplify the protocol generation code