compareItems function