return the index of the removed element