fixed searchItems function to search the primary collection multiple times