diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.cpp b/Source/Processors/Visualization/LfpDisplayCanvas.cpp
index f16e40f0955443fc6ba0ef34dd86063ecbdd6d47..ac7b79a12d16f083e7000a03fa251c23fffdb31f 100755
--- a/Source/Processors/Visualization/LfpDisplayCanvas.cpp
+++ b/Source/Processors/Visualization/LfpDisplayCanvas.cpp
@@ -292,6 +292,8 @@ void LfpDisplayCanvas::updateScreenBuffer()
 
             screenBuffer->clear(screenBufferIndex, 1);
 
+            displayBufferIndex = displayBufferIndex % displayBufferSize; // necessary to prevent crashes
+
             //if (displayBufferIndex<=index && nextPos<=index){
             for (int channel = 0; channel < nChans; channel++)
             {
@@ -597,7 +599,6 @@ void LfpDisplay::resized()
 
     canvas->fullredraw = true; //issue full redraw 
 
-   // std::cout << "Total height: " << totalHeight << std::endl;
 
 }