diff --git a/app/src/components/NodesLayer.vue b/app/src/components/NodesLayer.vue
index e870a08dd4820687aaa6e878ee6b0d72d849b842..bb1bd5582322e71e65d0e9f31615da4fcc799ee9 100644
--- a/app/src/components/NodesLayer.vue
+++ b/app/src/components/NodesLayer.vue
@@ -310,7 +310,7 @@ export default {
     },
     onDragstop(x, y, width, height, zindex) {
       var localnodeid = this.nodeid
-      zindex = this.pickupz
+      // zindex = this.pickupz
       width = this.width
       height = this.height
       var i
diff --git a/app/src/store/index.js b/app/src/store/index.js
index e36ca6d04a8bd784a8ba6fbccbdd705d1091d18f..04f1fc596678127fa4d8435b8815d70b5e1fd5c1 100644
--- a/app/src/store/index.js
+++ b/app/src/store/index.js
@@ -392,6 +392,8 @@ const store = new Vuex.Store({
 
     ADD_NODE(state) {
       var i
+      var totalNodes = []
+      const reducer = (accumulator, currentValue) => accumulator + currentValue
       for (i = 0; i < Object.keys(state.allNodes).length; i++) {
         if (
           state.allNodes[i].id != state.global_pos_name &&
@@ -399,12 +401,12 @@ const store = new Vuex.Store({
           state.allNodes[i].id != state.global_con_name //&&
           //
         ) {
-          // each loop gets the array
-          // add them each loop
-          var j = state.allNodes[i].doc.nodes.length
+          // console.log(state.allNodes[i].doc.nodes.length)
+          totalNodes.push(state.allNodes[i].doc.nodes.length)
         }
       }
 
+      var zindex = totalNodes.reduce(reducer)
       var uniqueid =
         Math.random().toString(36).substring(2, 15) +
         Math.random().toString(36).substring(2, 15)
@@ -475,7 +477,7 @@ const store = new Vuex.Store({
           y_pos: localypos,
           width: 200,
           height: 370,
-          z_index: 10,
+          z_index: zindex,
           read_mode: false,
         })
         return pouchdb