replace char with uint8_t to avoid dangerous overflows