diff --git a/eddy/runEddy b/eddy/runEddy
index 28f5c371045e754ed7185de935a81f08667cdbee..f62eb94b85efc4eb6391dc9b757cf5fd28a4a507 100755
--- a/eddy/runEddy
+++ b/eddy/runEddy
@@ -25,7 +25,7 @@ set -e
 # eddy. Don't pass the --out option, as that is
 # added by this script.
 exedir="$1"; shift;
-outdir="$2"; shift;
+outdir="$1"; shift;
 eddy_args="$@"
 
 # Find all eddy_cuda* executables
@@ -58,6 +58,10 @@ do
   tmp=`basename ${cuda_exe}`
   variant=`echo ${tmp} | sed 's/eddy_//'`
   jid=`fsl_sub -l ${outdir} -q cuda.q ${cuda_exe} --out=${outdir}/eddyOutput_${variant} ${eddy_args}`
+  if [ $? -ne 0 ]; then
+    echo "Error submitting ${cuda_exe} ${cuda_args}"
+    exit 1
+  fi
   cuda_jids="${cuda_jids} ${jid}"
 done
 
@@ -67,6 +71,10 @@ do
   tmp=`basename ${cuda_exe}`
   variant=`echo ${tmp} | sed 's/eddy_//'`
   jid=`fsl_sub -l ${outdir} -q long.q -s openmp,6 ${cpu_exe} --out=${outdir}/eddyOutput_${variant} ${eddy_args}`
+  if [ $? -ne 0 ]; then
+    echo "Error submitting ${cuda_exe} ${cuda_args}"
+    exit 1
+  fi    
   cpu_jids="${cpu_jids} ${jid}"
 done
 
@@ -81,7 +89,7 @@ if [ ! -z "${SGE_ROOT}" ]; then
   # on the queue for CPU jobs
   for jid in ${cpu_jids}; do
     qalter ${jid} -R y
-  fi
+  done
 
   # wait for all jobs to finish
   while [ : ]; do