reactive finite state machine