using encoding/binary to decode length field