made state type an unsigned char in order to make more storage available