implement state transition table.