replaced BYTE with unsigned char