A finite state machine