move routing logic out of State