simple finite state machine lib