router: refactoring