change logic for safe deleting