Are the elements not displayed in the user interface or are they not added to the array of elements?
I think we should compare the name of the item first, and only then do the other conditions.