added Encoding and Decoding of header