Use uint8_t for comparisons to avoid int conversions