refactor(router): refactor routing logic