fixed bug when an element may have multiple matches