finalize delete function