Change in delete method and infinite loop problem