Index: trunk/FACT++/scripts/Main.js
===================================================================
--- trunk/FACT++/scripts/Main.js	(revision 18380)
+++ trunk/FACT++/scripts/Main.js	(revision 18381)
@@ -409,32 +409,6 @@
 
     // FIXME: This might not work is the drive is already close to park position
-    dim.wait("DRIVE_CONTROL", "Locked", 3000);
-
-    //unlock drive if task was sleep
-    if (type=="sleep")
-        dim.send("DRIVE_CONTROL/UNLOCK");
-
-    var sub = new Subscription("DRIVE_CONTROL/POINTING_POSITION");
-    sub.get(5000);  // FIXME: Proper error message in case of failure
-
-    function func()
-    {
-        var report = sub.get();
-
-        var zd = report.obj['Zd'];
-        var az = report.obj['Az'];
-
-        if (zd>100 && Math.abs(az)<1)
-            return true;
-
-        return undefined;
-    }
-
-    try { v8.timeout(150000, func); }
-    catch (e)
-    {
-        var p = sub.get();
-        dim.log('Park position not reached? Telescope at Zd='+p.obj['Zd']+' Az='+p.obj['Az']);
-    }
+    //dim.wait("DRIVE_CONTROL", "Parking", 3000);
+
     /*
     // Check if DRS calibration is necessary
@@ -447,4 +421,5 @@
     }*/
 
+    //take single pe run if required
     if (type=="singlepe")
     {
@@ -459,4 +434,12 @@
         while (!irq && !takeRun("single-pe", 10000));
     }
+
+    //wait until drive is in locked (after it reached park position)
+    dim.wait("DRIVE_CONTROL", "Locked", 150000);
+
+    //unlock drive if task was sleep
+    if (type=="sleep")
+        dim.send("DRIVE_CONTROL/UNLOCK");
+
 
     // It is unclear what comes next, so we better switch off the voltage
@@ -486,4 +469,7 @@
         dim.wait("PWR_CONTROL",  "DriveOff",     6000);
     }
+
+    var sub = new Subscription("DRIVE_CONTROL/POINTING_POSITION");
+    sub.get(5000);  // FIXME: Proper error message in case of failure
 
     var report = sub.get();
