Exception handling and Logging added