updated encoding of messages