Added exception handling in main class.