integrate and use checksum code from @avsm