better implementation of the make_router method