a simple finite state machine simulater