toy finite state machine