Added try/catch block for main method