Tagged state-machine