Refactor AppRouter code