refactor routing system