fixed getting territory index