Added try-catch statement in main