change waiting to a set so that only unique elements are added to it