Simple finite state machine