change the protocol to make it consistent with c++ version