fix buffer
finish protocol