Finite State Machine Pattern Problem