Added conditional exit of script if failed.