           if child.indent <= noteParent.note.indent {
             break
           }
+          // remove
           section.append(self.notes.removeAtIndex(next))
         }
         
-        // insert section
+        // insert
+        func insert(section section: [Note], index: Int) {
+          // insert and save
+          self.notes.insertContentsOf(section, at: index)
+          Notebook.set(data: self)
+        }
+        
+        // insert section at start
         if toIndexPath.row == 0 {
-          self.notes.insertContentsOf(section, at: 0)
+          insert(section: section, index: 0)
           return
         }
         
-        let displayInsert = self.display[toIndexPath.row-1]
-        
-        
-        print(section)
-        print(self.notes)
+        // insert section at end
+        let displayPrev = self.display[toIndexPath.row-1]
+        var notePrev = self.getNoteParent(displayParent: displayPrev)
+        if notePrev.index+1 >= self.notes.count {
+          insert(section: section, index: notePrev.index+1)
+          return
+        }
+        
+        // insert section at mid
+        let next = notePrev.index+1
+        if next > notePrev.note.indent {
+          // find last child
+          for i in next..<self.notes.count {
+            let child = self.notes[i]
+            if child.indent <= notePrev.note.indent {
+              break
+            }
+            notePrev.index = i
+          }
+        }
 
-        
-        print("\n")
-        print(self)
-        // save
+        insert(section: section, index: notePrev.index+1)
       }
     }
   }

    Util.threadBackground {
      // uncollapse
      self.uncollapse(indexPath: toIndexPath, tableView: tableView) {
        
        print (toIndexPath.row, fromIndexPath.row)
        // display parent
        let displayParent = self.display[toIndexPath.row]
        
        // note parent
        let noteParent = self.getNoteParent(displayParent: displayParent)
        
        // remove section
        var section: [Note] = []
        let parent = self.notes.removeAtIndex(noteParent.index)
        section.append(parent)

        displayParent.children = count
        self.reload(indexPaths: [indexPath], tableView: tableView) {
          if let completion = completion {
            // handle complete and reorder
            completion(children: count)
          } else {
            // save
