fixing bug when inserting new records after a delete