working on packet encoding/decoding