fixed delete function