updated delete function