Changed exception handling for errors