Adding better error handling flag