adding finite state machine