Enclosed deletion function in try catch