Implementation of router.