diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 3102c4e..f9f8537 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -181,55 +181,55 @@
     {
       recursive_mutex::scoped_lock lock (m_stateMutex);
       
-      string last = name.substr(name.find_last_of("/") + 1);
-      istringstream ss (dataBuffer);
+  string last = name.substr(name.find_last_of("/") + 1);
+  istringstream ss (dataBuffer);
 
-      if (last == "state")
-        {
-          FullState full;
-          ss >> full;
+  if (last == "state")
+  {
+    FullState full;
+    ss >> full;
           BOOST_FOREACH (LeafConstPtr leaf, full.getLeaves()) // order doesn't matter
-            {
-              NameInfoConstPtr info = leaf->getInfo ();
-              SeqNo seq = leaf->getSeq ();
+    {
+      NameInfoConstPtr info = leaf->getInfo ();
+      SeqNo seq = leaf->getSeq ();
 
               bool inserted = false;
               bool updated = false;
               SeqNo oldSeq;
               tie (inserted, updated, oldSeq) = m_state.update (info, seq);
-                  
+
               if (updated)
                 {
                   diffLog->update (info, seq);
                   m_onUpdate (info->toString (), seq.getSeq(), oldSeq);
-                }
-            }
+    }
+  }
         }
-      else
-        {
-          DiffState diff;
-          ss >> diff;
-          BOOST_FOREACH (LeafConstPtr leaf, diff.getLeaves().get<ordered>())
-            {
+  else
+  {
+    DiffState diff;
+    ss >> diff;
+    BOOST_FOREACH (LeafConstPtr leaf, diff.getLeaves().get<ordered>())
+    {
               DiffLeafConstPtr diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
               BOOST_ASSERT (diffLeaf != 0);
 
-              NameInfoConstPtr info = diffLeaf->getInfo ();
+      NameInfoConstPtr info = diffLeaf->getInfo();
               if (diffLeaf->getOperation() == UPDATE)
                 {
-                  SeqNo seq = diffLeaf->getSeq ();
-                  
+      SeqNo seq = diffLeaf->getSeq();
+
                   bool inserted = false;
                   bool updated = false;
                   SeqNo oldSeq;
                   tie (inserted, updated, oldSeq) = m_state.update (info, seq);
-                  
+
                   if (updated)
                     {
                       diffLog->update (info, seq);
                       m_onUpdate (info->toString (), seq.getSeq(), oldSeq);
-                    }
-                }
+    }
+  }
               else if (diffLeaf->getOperation() == REMOVE)
                 {
                   if (m_state.remove (info))
@@ -245,8 +245,8 @@
             }
         }
 
-      diffLog->setDigest(m_state.getDigest());
-      m_log.insert (diffLog);
+  diffLog->setDigest(m_state.getDigest());
+  m_log.insert (diffLog);
     }
   catch (Error::SyncXmlDecodingFailure &e)
     {
@@ -256,29 +256,37 @@
 
   if (diffLog->getLeaves ().size () > 0)
     {
-      // notify upper layer
-      BOOST_FOREACH (LeafConstPtr leaf, diffLog->getLeaves ())
-        {
+  // notify upper layer
+  BOOST_FOREACH (LeafConstPtr leaf, diffLog->getLeaves ())
+    {
           DiffLeafConstPtr diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
           BOOST_ASSERT (diffLeaf != 0);
           
             // m_fetchCallback (prefix, 1, seq.getSeq());
-        }
-
-      sendSyncInterest ();
     }
+  
+  sendSyncInterest();
+}
 }
 
 void
-SyncLogic::addLocalNames (const string &prefix, uint32_t session, uint32_t seq)
+SyncLogic::processPendingSyncInterests(DiffStatePtr &diff) {
+  diff->setDigest(m_state.getDigest());
+	m_log.insert(diff);
+
+  vector<string> pis = m_syncInterestTable.fetchAll ();
+  stringstream ss;
+  ss << *diff;
+  for (vector<string>::iterator ii = pis.begin(); ii != pis.end(); ++ii)
+  {
+    m_ccnxHandle->publishData (*ii, ss.str(), m_syncResponseFreshness);
+  }
+}
+
+void
+SyncLogic::processPendingSyncInterests(DiffStatePtr &diff) 
 {
   recursive_mutex::scoped_lock lock (m_stateMutex);
-
-  NameInfoConstPtr info = StdNameInfo::FindOrCreate (prefix);
-  SeqNo seqN(session, seq);
-  DiffStatePtr diff = make_shared<DiffState>();
-  diff->update(info, seqN);
-  m_state.update(info, seqN);
   diff->setDigest(m_state.getDigest());
   m_log.insert(diff);
 
@@ -292,6 +300,33 @@
 }
 
 void
+SyncLogic::addLocalNames (const string &prefix, uint32_t session, uint32_t seq)
+{
+  recursive_mutex::scoped_lock lock (m_stateMutex);
+  NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix);
+  SeqNo seqN(session, seq);
+  m_state.update(info, seqN);
+
+  DiffStatePtr diff = make_shared<DiffState>();
+  diff->update(info, seqN);
+
+  processPendingSyncInterests(diff);
+}
+
+void
+SyncLogic::remove(const string &prefix) 
+{
+  recursive_mutex::scoped_lock lock (m_stateMutex);
+  NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix);
+  m_state.remove(info);	
+
+  DiffStatePtr diff = make_shared<DiffState>();
+  diff->remove(info);
+
+  processPendingSyncInterests(diff);
+}
+
+void
 SyncLogic::sendSyncInterest ()
 {
   recursive_mutex::scoped_lock lock (m_stateMutex);
