The one wizard help

Is there something wrong with my code?

# Defeat as many ogres as you can.
# Use 'cast' and 'canCast' for spells.
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        if hero.canCast("chain-lightning"):
            hero.cast("chain-lightning", enemy)
    elif enemy:
        if hero.canCast("lightning-bolt"):
            hero.cast("lightning-bolt", enemy)
    else:
        hero.moveXY(28, 16)