diff --git a/src/simudator/gui/module_graphics_item/integer_memory_graphic.py b/src/simudator/gui/module_graphics_item/integer_memory_graphic.py
index a177b6228b5395a5c163bf8d1c371f4e0f0a923a..c746c082c3fcc3e33d16b20949415b833cdfcf07 100644
--- a/src/simudator/gui/module_graphics_item/integer_memory_graphic.py
+++ b/src/simudator/gui/module_graphics_item/integer_memory_graphic.py
@@ -248,6 +248,6 @@ class IntegerMemoryTable(MemoryTable):
         # -7 + 16 % 16 = 9 = 1001 = -7
         value = (value + max_value) % max_value
 
-        index = row * 4 + col
+        index = row * self._column_size + col
         state['memory'][index] = value
         self._memory.set_state(state)
diff --git a/src/simudator/gui/module_graphics_item/memory_graphic.py b/src/simudator/gui/module_graphics_item/memory_graphic.py
index c4a944d213270e0f99330c5dede4d914dfc2a611..1016a3ba07f721794a26792a9925c2f6fc3a4ce6 100644
--- a/src/simudator/gui/module_graphics_item/memory_graphic.py
+++ b/src/simudator/gui/module_graphics_item/memory_graphic.py
@@ -35,7 +35,7 @@ class MemoryWindow(QWidget):
         An instance of the Memory base class.
     edit_buttons: bool
         A bool deciding whether or not to add buttons to the widget
-        for toggling between setting the memory contents to 
+        for toggling between setting the memory contents to
         editable or not.
     """
 
@@ -196,7 +196,7 @@ class MemoryTable(QTableWidget):
         value = item.text()
         if value == "":
             return
-        index = row * 4 + col
+        index = row * self._column_size + col
         state['memory'][index] = value
         self._memory.set_state(state)