fixed script to break on error and continue on restart