It's unlikely for someone to have enough names that this is an issue, but you can break out of the loop after finding a primary name so you don't have to check all of them.