finite state machine (fsm) implementation for node.js