add geometric median funcionality to region code