iterating through all tag combinations correctly