loop was broken: actually change the list of wim.ids

moved the modification of wim.ids inside the while loop!