changed exception handling for the better