diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index f725d71da6215332faa6b4b94a0f71377828688e..70c08042b33e006234ed3152293a75499f1517b5 100755
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -869,18 +869,18 @@ void MainWindow::slotCurrentAction(QString msg)
 
 void MainWindow::slotFrameNumber(unsigned long actualFrameCount)
 {
-    QString msg;
-    msg.setNum(actualFrameCount);
-
-    ui.frameSliderLabel->setText("Frame: " + msg);
 
     //compute the  mamixum framenumber
     int maxFrameCount=1;
     if(extern_first_dataset_loaded) {
         maxFrameCount=extern_trajectories_firstSet.getFramesNumber();
-
     }
 
+    if(actualFrameCount>maxFrameCount) actualFrameCount=maxFrameCount;
+    QString msg;
+    msg.setNum(actualFrameCount);
+    ui.frameSliderLabel->setText("Frame: " + msg);
+
     if(!frameSliderHold)if(maxFrameCount!=0)//TODO WTF, otherwise an arrymtic exeption arises
         ui.framesIndicatorSlider->setValue((ui.framesIndicatorSlider->maximum()*actualFrameCount)/maxFrameCount);
 }