fixing bug with exception rescue