refactored the router