fixed checksum calculation