moved exception handling to 'raise'