fixes npe bug when deleting