calculate checksum first