Fix NPC iteration in certain cases