A state-based router