Refactored the design of router