Pet is glitching

Level Name: Pet Adjutant
In-game username: A.Lee452
Description of the bug: The pet keeps moving above and below the x and it seems like it can’t get on it and it won’t say fire.
Code:

# Your pet can help you survive until you can escape.

def onHear(event):
    # event.message contains the text that was heard.
    # If somebody said "Fire"
    if event.message == "Fire":
        # Move to the bottom X mark with pet.moveXY()
        pet.moveXY(64,16)
        # Say something with pet.say()
        hero.say("Fire")
        pass
    # If somebody said "Heal"
    elif event.message == "Heal":
        # Move to the top X mark with pet.moveXY()
        pet.moveXY(63,53)
        # Say something with pet.say()
        hero.say("Heal")
        pass

pet.on("hear", onHear)

# You don't have to change the code below.
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        # If an enemy is too strong.
        if enemy.type == "brawler":
            hero.say("Fire")
        else:
            hero.attack(enemy)
    else:
        # If your hero needs healing.
        if hero.health < hero.maxHealth / 2:
            hero.say("Heal")