fix it so that length is checked before checksum to avoid weird segfault edge case