diff --git a/demo/digesttreescene.cpp b/demo/digesttreescene.cpp
index 2d2f631..5133e4c 100644
--- a/demo/digesttreescene.cpp
+++ b/demo/digesttreescene.cpp
@@ -10,9 +10,33 @@
 
 static const double Pi = 3.14159265358979323846264338327950288419717;
 
+static void 
+testDraw(DigestTreeScene * scene) 
+{
+  std::string prefix[5] = {"/ndn/1", "/ndn/2", "/ndn/3", "/ndn/4", "/ndn/5"};
+  std::string nick[5] = {"tom", "jerry", "jason", "michael", "hurry"};
+  std::vector<Sync::MissingDataInfo> v;
+  for (int i = 0; i < 5; i++)
+  {
+    Sync::MissingDataInfo mdi = {prefix[i], Sync::SeqNo(0), Sync::SeqNo(i * (2 << i) )};
+    v.push_back(mdi);
+  }
+
+  scene->processUpdate(v, "12341234@!#%!@");
+
+  for (int i = 0; i < 5; i++)
+  {
+   scene-> msgReceived(prefix[i].c_str(), nick[i].c_str());
+  }
+}
+
+DigestTreeScene::DisplayUserPtr DigestTreeScene::DisplayUserNullPtr;
+
 DigestTreeScene::DigestTreeScene(QWidget *parent)
   : QGraphicsScene(parent)
 {
+  previouslyUpdatedUser = DisplayUserNullPtr;
+  testDraw(this);
 }
 
 void
@@ -44,8 +68,12 @@
       if (it != m_roster.end()) {
         DisplayUserPtr p = it.value();
         QGraphicsTextItem *item = p->getSeqTextItem();
+        QGraphicsRectItem *rectItem = p->getInnerRectItem();
         std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
         item->setPlainText(s.c_str());
+        QRectF textBR = item->boundingRect();
+        QRectF rectBR = rectItem->boundingRect();
+        item->setPos(rectBR.x() + (rectBR.width() - textBR.width())/2, rectBR.y() + (rectBR.height() - textBR.height())/2);
       }
     }
     m_rootDigest->setPlainText(digest);
@@ -53,6 +81,21 @@
 }
 
 void
+DigestTreeScene::reDrawNode(DisplayUserPtr p, QColor rimColor)
+{
+    QGraphicsRectItem *rimItem = p->getRimRectItem();
+    rimItem->setBrush(QBrush(rimColor));
+    QGraphicsRectItem *innerItem = p->getInnerRectItem();
+    innerItem->setBrush(QBrush(Qt::lightGray));
+    QGraphicsTextItem *seqTextItem = p->getSeqTextItem();
+    std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
+    seqTextItem->setPlainText(s.c_str());
+    QRectF textBR = seqTextItem->boundingRect();
+    QRectF innerBR = innerItem->boundingRect();
+    seqTextItem->setPos(innerBR.x() + (innerBR.width() - textBR.width())/2, innerBR.y() + (innerBR.height() - textBR.height())/2);
+}
+
+void
 DigestTreeScene::msgReceived(QString prefix, QString nick)
 {
   Roster_iterator it = m_roster.find(prefix);
@@ -62,10 +105,21 @@
     if (nick != p->getNick()) {
       p->setNick(nick);
       QGraphicsTextItem *nickItem = p->getNickTextItem();
+      QGraphicsRectItem *nickRectItem = p->getNickRectItem();
       nickItem->setPlainText(p->getNick());
+      QRectF rectBR = nickRectItem->boundingRect();
+      QRectF nickBR = nickItem->boundingRect();
+      nickItem->setPos(rectBR.x() + (rectBR.width() - nickBR.width())/2, rectBR.y() + 5);
     }
-    QGraphicsRectItem *rimItem = p->getRimRectItem();
-    rimItem->setBrush(QBrush(Qt::red));
+
+    reDrawNode(p, Qt::red);
+
+    if (previouslyUpdatedUser != DisplayUserNullPtr) 
+    {
+      reDrawNode(previouslyUpdatedUser, Qt::darkBlue);
+    }
+
+    previouslyUpdatedUser = p;
   }
 }
 
@@ -83,7 +137,7 @@
   }
   ogdf::GraphAttributes GA(m_graph);
 
-  int nodeSize = 50;
+  int nodeSize = 40;
   int siblingDistance = 100, levelDistance = 100;
   ogdf::TreeLayout layout;
   layout.siblingDistance(siblingDistance);
@@ -92,13 +146,15 @@
 
   int width = GA.boundingBox().width();
   int height = GA.boundingBox().height();
-  setSceneRect(QRect(- (width + nodeSize) / 2, - 40, width + nodeSize, height + nodeSize));
+  //setSceneRect(QRect(- (width + nodeSize) / 2, - 50, width + nodeSize, height + nodeSize));
   GA.setAllWidth(nodeSize);
   GA.setAllHeight(nodeSize);
 
   plotEdge(GA);
   plotNode(GA, rootIndex, digest);
 
+  previouslyUpdatedUser = DisplayUserNullPtr;
+
 }
 
 void
@@ -141,19 +197,19 @@
     int rim = 3;
     QRectF boundingRect(x, y, w, h);
     QRectF innerBoundingRect(x + rim, y + rim, w - rim * 2, h - rim * 2);
-    addRect(innerBoundingRect, QPen(Qt::black), QBrush(Qt::lightGray));
 
     if (n->index() == rootIndex) 
     {
       addRect(boundingRect, QPen(Qt::black), QBrush(Qt::darkRed));
+      addRect(innerBoundingRect, QPen(Qt::black), QBrush(Qt::lightGray));
 
-      QRectF digestRect(x - w / 2, y - h - 5, 2 * w, 30);
+      QRectF digestRect(x - w, y - h, 3 * w, 30);
       addRect(digestRect, QPen(Qt::darkCyan), QBrush(Qt::darkCyan));
       QGraphicsTextItem *digestItem = addText(digest);
       QRectF digestBoundingRect = digestItem->boundingRect();
       digestItem->setDefaultTextColor(Qt::white);
       digestItem->setFont(QFont("Cursive", 12, QFont::Bold));
-      digestItem->setPos(x + w / 2 - digestBoundingRect.width() / 2, y - h - 15);
+      digestItem->setPos(x - w + (3 * w - digestBoundingRect.width()) / 2, y - h + 5);
       m_rootDigest = digestItem;
     }
     else
@@ -170,6 +226,9 @@
       QGraphicsRectItem *rectItem = addRect(boundingRect, QPen(Qt::black), QBrush(Qt::darkBlue));
       p->setRimRectItem(rectItem);
 
+      QGraphicsRectItem *innerRectItem = addRect(innerBoundingRect, QPen(Qt::black), QBrush(Qt::lightGray));
+      p->setInnerRectItem(innerRectItem);
+
       std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
       QGraphicsTextItem *seqItem = addText(s.c_str());
       seqItem->setFont(QFont("Cursive", 12, QFont::Bold));
@@ -177,15 +236,17 @@
       seqItem->setPos(x + w / 2 - seqBoundingRect.width() / 2, y + h / 2 - seqBoundingRect.height() / 2);
       p->setSeqTextItem(seqItem);
 
-      QRectF textRect(x - w / 2, y + h + 10, 2 * w, 30);
-      addRect(textRect, QPen(Qt::darkCyan), QBrush(Qt::darkCyan));
+      QRectF textRect(x - w / 2, y + h, 2 * w, 30);
+      QGraphicsRectItem *nickRectItem = addRect(textRect, QPen(Qt::darkCyan), QBrush(Qt::darkCyan));
+      p->setNickRectItem(nickRectItem);
       QGraphicsTextItem *nickItem = addText(p->getNick());
       QRectF textBoundingRect = nickItem->boundingRect();
       nickItem->setDefaultTextColor(Qt::white);
       nickItem->setFont(QFont("Cursive", 12, QFont::Bold));
-      nickItem->setPos(x + w / 2 - textBoundingRect.width() / 2, y + h + 15);
+      nickItem->setPos(x + w / 2 - textBoundingRect.width() / 2, y + h + 5);
       p->setNickTextItem(nickItem);
     }
+
   }
 }
 
