moved checksum calculation to own function