reading function and checksum check added