modified the exeception handling of the example