Refactor the register router