found possible modification of newSlices within foreach, changed to
iterator and used iterator remove.