corrected delete function