don't use crc_check and mode as global variables