Implemented Exception handling