Exception handling and small correction