implement checksum function