diff --git a/editor/js/manageddata.js b/editor/js/manageddata.js
index 170ccc4c02bd3cb55219effc6501374090cd118c..05e18692786ef02ebe31cbb1e987f47c322e6312 100644
--- a/editor/js/manageddata.js
+++ b/editor/js/manageddata.js
@@ -1,7 +1,7 @@
 export default class ManagedData {
     constructor(data) {
         this.data = data;
-        this.history = [];
+        this.history = [];  // Newest state is always at 0
         this.historyPosition = 0;
 
         this.storeCurrentData("Initial state");
@@ -11,27 +11,32 @@ export default class ManagedData {
     onRedo() {}
 
     undo() {
-        if (this.historyPosition + 1 >= this.history.length) {
+        if (this.step(1)) {
+            this.onUndo();
+            return true;
+        } else {
             return false;
         }
-
-        this.historyPosition += 1;
-        this.data = JSON.parse(this.history[this.historyPosition].data);
-
-        this.onUndo();
-
-        return true;
     }
 
     redo() {
-        if (this.historyPosition <= 0) {
+        if (this.step(-1)) {
+            this.onRedo();
+            return true;
+        } else {
             return false;
         }
+    }
 
-        this.historyPosition -= 1;
-        this.data = JSON.parse(this.history[this.historyPosition].data);
+    step(direction = 1) {
+        var newHistoryPosition = this.historyPosition + Math.sign(direction);
 
-        this.onRedo();
+        if (newHistoryPosition >= this.history.length || newHistoryPosition < 0) {
+            return false;
+        }
+
+        this.historyPosition = newHistoryPosition;
+        this.data = JSON.parse(this.history[this.historyPosition].data);
 
         return true;
     }