codes refactoring for routers related codes