Changed exception handling for main