Added an option to stop after first failure