fixed bugs with message encoder