updated error management: retry 3 times before exiting in case uncaught error occurs