Added exception handling to make cli more resilient