taking a FSM approach to this.