implement the checksum algorithm