A simple finite state machine