improve NPC logic