Replace arrayList with hashSet for tagged and not tagged