refactor the router