corrected exception handling