[enhancement] moved the routing logic into a Router constructor