add judge for deleting