updated delete function.