cleaned up code in router.js