diff --git a/lib/nBodySim.cpp b/lib/nBodySim.cpp
index 181ca1532f8c4fd8799a9011e9319d906ebc3e1e..c47a32fa04ef4e4579e267b97011e6009f3f27ac 100644
--- a/lib/nBodySim.cpp
+++ b/lib/nBodySim.cpp
@@ -62,7 +62,9 @@ nBodySim::~nBodySim() {
 
 void nBodySim::runSimulation(double dt, unsigned nSteps) {
     for (unsigned i=0; i < nSteps; ++i) {
+        treeCalculateForces();
         doTimeStep(dt);
+        updateTree();
     }
 }
 
@@ -157,18 +159,20 @@ double nBodySim::calculateMeanForceMagnitude() {
 }
 
 void nBodySim::doTimeStep(double dt) {
+    // update velocities, then positions
     #pragma omp parallel for
     for (unsigned i=0; i < nParticles_; ++i) {
         for (unsigned j=0; j < 3; ++j) {
-            // TODO
-            tree_->kick(dt/2);
-            tree_->drift(dt);
-            tree_->update();
-            tree_->kick(dt/2);
+            velocities_[3*i+j] += 0.5 * forces_[3*i+j] * dt / masses_[i];
+            positions_[3*i+j] += velocities_[3*i+j] * dt;
         }
     }
 }
 
+void nBodySim::updateTree() {
+    tree_->update();
+}
+
 void nBodySim::write2file(const double* array, std::string filename, unsigned dim) const {
     // writes array to file, with N rows and dim columns
     std::ofstream file(filename);
diff --git a/lib/nBodySim.hpp b/lib/nBodySim.hpp
index cd9fbc897d84c69bdf153aef5e7935ae7859bad2..380bce409b682a11aac3b54b56f99308bb220f0b 100644
--- a/lib/nBodySim.hpp
+++ b/lib/nBodySim.hpp
@@ -20,8 +20,10 @@ public:
     double calculateMeanInterparticleDistance();
     // loop over all force vectors and calculate mean force magnitude
     double calculateMeanForceMagnitude();
-    // updates positions and velocities using the calculated forces
+    // integrate using leapfrog algorithm. doesn't update forces, doesn't update tree
     void doTimeStep(double dt);
+    // update tree
+    void updateTree();
     // writes data to file, every row is a particle
     void write2file(const double* array, std::string filename, unsigned dim) const;
     // write current state of simulation to file