[task] changed loop to an ImmutableSet copy