fixed iterator issue and random_shuffle of node IDs at at each iteration