Small refactoring of the router