refractored router.js