small bug in encoding the message