Moved router related code to router.js