switched ff operation from lookup table to state machine