fixed issue in delete method where exception is being used outside try
catch block