move deleting notification logic to standalone function