refactoring router.js