refactored router.coffee