Fixed an exception handling bug