Well if I am following your code correctly the reason why your delrep() only deletes the first occurence is because there is nothing telling it to continue deleting after the first occurence.