Added exception throwing and catching