delete method with some error catching