tidied delete function