some bugs in calculating the length of the message and reading in checksum value