fixed logic in filterItems function