fix packet read/write