fix handling of exception