calculate checksum correctly