Added condition before deleing DB