Refactored the router a bit