fixing iteration bug

previously we were removing element from list on which we were iterating so if we follow such process it will miss one element.
eg:
>>> a = range(10)
>>> for each in a:
...     a.remove(each)
... 
>>> a
[1, 3, 5, 7, 9]

Above example show that it is not removing all the elements because when we do a.remove it will change the index of all the elements present in list a.


To fix this, I am copying the elements of a list to another list and iterating on one list and removing elements from another list.