further refactored router.js