```
while True:
bestCoin = None
maxRating = 0
coinIndex = 0
coins = hero.findItems()
# Try calculating "value / distance" to decide which coins to get.
for coin in coins:
if coinIndex < len(coins):
value = coin.value
distance = hero.distanceTo(coin)
if value / distance > maxRating:
bestCoin = coin
maxRating = value / distance
coinIndex += 1
if bestCoin:
hero.move(bestCoin.pos)```
This is my code - can anyone help point me towards what I am doing wrong? Thanks
```

# [Solved] Mad Maxer Gets Greedy

**mratranslate**#1

**Enderlord832**#2

You have to update `coinIndex`

after you move to the best coin.Also you should use moveXY because it is the one that’s required to use in this level. move() is from the mountain levels. And this level uses moveXY @mratranslate

**mratranslate**#9

```
while True:
bestCoin = None
maxRating = 0
coinIndex = 0
coins = hero.findItems()
# Try calculating "value / distance" to decide which coins to get.
for coin in coins:
if coinIndex < len(coins):
value = coin.value
distance = hero.distanceTo(coin)
if value / distance > maxRating:
bestCoin = coin
maxRating = value / distance
if bestCoin:
hero.moveXY(bestCoin.pos.x, bestCoin.pos.y)
coinIndex += 1
```

I changed my code to add to index as you said but it doesn’t work still. Anya collects far too slow to beat the CPU and also at times it says “I can’t get there”. Also I used moveXY as you said but the actual hints say to use ‘move’. Either way it doesn’t work

**mratranslate**#10

I got some help and it seems the final if statement should match-up to for coin in coins. Also I used ‘move’. Then it worked.