diff --git a/src/nlsr_dm.cpp b/src/nlsr_dm.cpp
index 1f3beab..8252423 100644
--- a/src/nlsr_dm.cpp
+++ b/src/nlsr_dm.cpp
@@ -6,76 +6,78 @@
 #include "nlsr_tokenizer.hpp"
 #include "nlsr_lsdb.hpp"
 
-namespace nlsr {
-
-using namespace std;
-using namespace ndn;
-
-void
-DataManager::processContent(Nlsr& pnlsr, const ndn::Interest &interest,
-								               const ndn::Data & data)
+namespace nlsr
 {
 
-	cout << "I: " << interest.toUri() << endl;
+    using namespace std;
+    using namespace ndn;
 
-	string dataName(data.getName().toUri());
-	string dataContent((char *)data.getContent().value());
-	
-  	cout << "D: " << dataName << endl;
-	cout << "Data Content: " << dataContent << endl;
+    void
+    DataManager::processContent(Nlsr& pnlsr, const ndn::Interest &interest,
+                                const ndn::Data & data)
+    {
 
-	nlsrTokenizer nt(dataName,"/");
-	string chkString("info");
-	if( nt.doesTokenExist(chkString) ){
-		processContentInfo(pnlsr,dataName,dataContent);
-	}
+        cout << "I: " << interest.toUri() << endl;
 
-}
+        string dataName(data.getName().toUri());
+        string dataContent((char *)data.getContent().value());
 
-void
-DataManager::processContentInfo(Nlsr& pnlsr, string& dataName,
-                                                           string& dataContent)
-{
-	nlsrTokenizer nt(dataName,"/");
-	string chkString("info");
-	string neighbor="/" + nt.getFirstToken()
-							+nt.getTokenString(0,nt.getTokenPosition(chkString)-1);
-	int oldStatus=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
-	int infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor);
-	//debugging purpose start
-	cout <<"Before Updates: " <<endl;
-	cout <<"Neighbor : "<<neighbor<<endl;
-	cout<<"Status: "<< oldStatus << endl;
-	cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
-	//debugging purpose end
+        cout << "D: " << dataName << endl;
+        cout << "Data Content: " << dataContent << endl;
 
-	pnlsr.getAdl().setStatusOfNeighbor(neighbor,1);
-	pnlsr.getAdl().setTimedOutInterestCount(neighbor,0);
+        nlsrTokenizer nt(dataName,"/");
+        string chkString("info");
+        if( nt.doesTokenExist(chkString) )
+        {
+            processContentInfo(pnlsr,dataName,dataContent);
+        }
 
-	int newStatus=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
-	infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+    }
 
-	//debugging purpose
-	cout <<"After Updates: " <<endl;
-	cout <<"Neighbor : "<<neighbor<<endl;
-	cout<<"Status: "<< newStatus << endl;
-	cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
-	//debugging purpose end
+    void
+    DataManager::processContentInfo(Nlsr& pnlsr, string& dataName,
+                                    string& dataContent)
+    {
+        nlsrTokenizer nt(dataName,"/");
+        string chkString("info");
+        string neighbor="/" + nt.getFirstToken()
+                        +nt.getTokenString(0,nt.getTokenPosition(chkString)-1);
+        int oldStatus=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
+        int infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+        //debugging purpose start
+        cout <<"Before Updates: " <<endl;
+        cout <<"Neighbor : "<<neighbor<<endl;
+        cout<<"Status: "<< oldStatus << endl;
+        cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
+        //debugging purpose end
 
-	if ( ( oldStatus-newStatus)!= 0 ) // change in Adjacency list
-	{
-		pnlsr.incrementAdjBuildCount();
-		/* Need to schedule event for Adjacency LSA building */
-		if ( pnlsr.getIsBuildAdjLsaSheduled() == 0 )
-		{
-			pnlsr.setIsBuildAdjLsaSheduled(1);
-			// event here
-			pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
-							ndn::bind(&Lsdb::scheduledAdjLsaBuild, pnlsr.getLsdb(), 
-																									boost::ref(pnlsr)));
-		}
-		
-	}
-}
+        pnlsr.getAdl().setStatusOfNeighbor(neighbor,1);
+        pnlsr.getAdl().setTimedOutInterestCount(neighbor,0);
+
+        int newStatus=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
+        infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+
+        //debugging purpose
+        cout <<"After Updates: " <<endl;
+        cout <<"Neighbor : "<<neighbor<<endl;
+        cout<<"Status: "<< newStatus << endl;
+        cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
+        //debugging purpose end
+
+        if ( ( oldStatus-newStatus)!= 0 ) // change in Adjacency list
+        {
+            pnlsr.incrementAdjBuildCount();
+            /* Need to schedule event for Adjacency LSA building */
+            if ( pnlsr.getIsBuildAdjLsaSheduled() == 0 )
+            {
+                pnlsr.setIsBuildAdjLsaSheduled(1);
+                // event here
+                pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
+                                                   ndn::bind(&Lsdb::scheduledAdjLsaBuild, pnlsr.getLsdb(),
+                                                           boost::ref(pnlsr)));
+            }
+
+        }
+    }
 
 }//namespace nlsr
