implement C2S and fix bug