refactor updateTerritory