diff --git a/nlsr_adjacent.cpp b/nlsr_adjacent.cpp
index c8821c1..8a1c048 100644
--- a/nlsr_adjacent.cpp
+++ b/nlsr_adjacent.cpp
@@ -1,5 +1,7 @@
 #include<iostream>
 #include<string>
+#include<cmath>
+#include<limits>
 
 #include "nlsr_adjacent.hpp"
 
@@ -13,6 +15,15 @@
 	interestTimedOutNo=iton;
 }
 
+bool 
+Adjacent::isAdjacentEqual(Adjacent& adj)
+{
+	return ( adjacentName == adj.getAdjacentName() ) && 
+	       ( connectingFace == adj.getConnectingFace() ) &&
+	       (std::abs(linkCost - adj.getLinkCost()) < 
+	                                    std::numeric_limits<double>::epsilon()) ;
+}
+
 std::ostream&
 operator << (std::ostream &os, Adjacent &adj){
 	cout<<"Adjacent : "<< adj.getAdjacentName()	<< endl;
diff --git a/nlsr_adjacent.hpp b/nlsr_adjacent.hpp
index 2f5106f..910b8a9 100644
--- a/nlsr_adjacent.hpp
+++ b/nlsr_adjacent.hpp
@@ -65,6 +65,8 @@
 		void setInterestTimedOutNo(int iton){
 			interestTimedOutNo=iton;
 		}
+
+		bool isAdjacentEqual(Adjacent& adj);
 	private:
 		string adjacentName;
 		int connectingFace;
diff --git a/nlsr_adl.cpp b/nlsr_adl.cpp
index 055a792..eaf0699 100644
--- a/nlsr_adl.cpp
+++ b/nlsr_adl.cpp
@@ -28,6 +28,17 @@
 	adjList.push_back(adj);
 	return 0;
 }
+
+void 
+Adl::addAdjacentsFromAdl(Adl& adl)
+{
+	for(std::list<Adjacent >::iterator it=adl.getAdjList().begin();
+	                                             it!=adl.getAdjList().end(); ++it)
+	{
+		insert((*it));
+	}
+}
+
 int
 Adl::updateAdjacentStatus(string adjName, int s){
 	Adjacent adj(adjName);
@@ -62,6 +73,37 @@
 	return adj;
 }
 
+
+bool 
+Adl::isAdlEqual(Adl &adl)
+{
+	if ( getAdlSize() != adl.getAdlSize() )
+	{
+		return false;
+	}
+
+	adjList.sort(adjacent_compare);	
+	adl.getAdjList().sort(adjacent_compare);
+	int equalAdjCount=0;
+
+	std::list< Adjacent > adjList2=adl.getAdjList();
+
+	std::list<Adjacent>::iterator it1;
+	std::list<Adjacent>::iterator it2;
+	for(it1=adjList.begin() , it2=adjList2.begin() ; 
+	                                              it1!=adjList.end(); it1++,it2++)
+	{
+		if ( !(*it1).isAdjacentEqual((*it2)) )
+		{
+			break;
+		}
+		equalAdjCount++;
+	}
+
+	return equalAdjCount==getAdlSize();
+}
+
+
 int 
 Adl::updateAdjacentLinkCost(string adjName, double lc){
 	Adjacent adj(adjName);
diff --git a/nlsr_adl.hpp b/nlsr_adl.hpp
index ec5cf96..0d868ae 100644
--- a/nlsr_adl.hpp
+++ b/nlsr_adl.hpp
@@ -24,16 +24,27 @@
 	int getStatusOfNeighbor(string& neighbor);
 	void setStatusOfNeighbor(string& neighbor, int status);
 	void setTimedOutInterestCount(string& neighbor, int count);
+	void addAdjacentsFromAdl(Adl& adl);
 
 	bool isAdjLsaBuildable(nlsr& pnlsr);
 	int getNumOfActiveNeighbor();
 	Adjacent getAdjacent(string adjName);
 
+	bool isAdlEqual(Adl &adl);
+
 	int getAdlSize()
 	{
 		return adjList.size();
 	}
 
+	void resetAdl()
+	{
+		if( adjList.size() > 0 )
+		{
+			adjList.clear();
+		}
+	}
+
 	void printAdl();
 
 private:	
diff --git a/nlsr_fib.cpp b/nlsr_fib.cpp
index a1e4968..2bfc568 100644
--- a/nlsr_fib.cpp
+++ b/nlsr_fib.cpp
@@ -58,6 +58,7 @@
   				(*it).getNhl().addNextHop((*nhit));
   			}
   		}
+  		(*it).getNhl().sortNhl();
   }
   else
   {
@@ -67,6 +68,7 @@
   		{
   			newEntry.getNhl().addNextHop((*nhit));
   		}
+  		newEntry.getNhl().sortNhl();
   		fibTable.push_back(newEntry);	
   }
 }
@@ -127,6 +129,7 @@
 	for(std::list<FibEntry>::iterator it = fibTable.begin(); it!=fibTable.end();
 	                                                                         ++it)
 	{
+		//(*it).getNhl().sortNhl();
 		cout<<(*it);
 	}
 }
diff --git a/nlsr_lsa.cpp b/nlsr_lsa.cpp
index 38d3fd5..6eebb16 100644
--- a/nlsr_lsa.cpp
+++ b/nlsr_lsa.cpp
@@ -1,10 +1,13 @@
 #include<string>
 #include<iostream>
 #include<algorithm>
+#include<cmath>
+#include<limits>
 
 #include "nlsr_lsa.hpp"
 #include "nlsr_npl.hpp"
 #include "nlsr_adjacent.hpp"
+#include "nlsr.hpp"
 
 using namespace std;
 
@@ -93,6 +96,15 @@
 	return key;
 }
 
+bool 
+CorLsa::isLsaContentEqual(CorLsa& clsa)
+{
+	return (std::abs(corRad - clsa.getCorRadius()) < 
+	                                    std::numeric_limits<double>::epsilon()) &&
+	       (std::abs(corTheta - clsa.getCorTheta()) < 
+	                                    std::numeric_limits<double>::epsilon());
+}
+
 string 
 CorLsa::getCorLsaData()
 {
@@ -149,6 +161,13 @@
 	return key;
 }
 
+bool 
+AdjLsa::isLsaContentEqual(AdjLsa& alsa)
+{
+	return adl.isAdlEqual(alsa.getAdl());
+}
+
+
 string 
 AdjLsa::getAdjLsaData(){
 	string adjLsaData;
@@ -172,6 +191,29 @@
 	return adjLsaData;
 }
 
+
+void 
+AdjLsa::addNptEntriesForAdjLsa(nlsr& pnlsr)
+{
+	if ( getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
+	{
+		pnlsr.getNpt().addNpte(getOrigRouter(), getOrigRouter(),pnlsr);
+	}
+
+}
+
+
+void 
+AdjLsa::removeNptEntriesForAdjLsa(nlsr& pnlsr)
+{
+	if ( getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
+	{
+		pnlsr.getNpt().removeNpte(getOrigRouter(), getOrigRouter(),pnlsr);
+	}
+}
+
+
+
 std::ostream& 
 operator<<(std::ostream& os, AdjLsa& aLsa) 
 {
diff --git a/nlsr_lsa.hpp b/nlsr_lsa.hpp
index a75f572..0f3e528 100644
--- a/nlsr_lsa.hpp
+++ b/nlsr_lsa.hpp
@@ -127,6 +127,10 @@
 		return noLink;
 	}
 
+	bool isLsaContentEqual(AdjLsa& alsa);
+	void addNptEntriesForAdjLsa(nlsr& pnlsr);
+	void removeNptEntriesForAdjLsa(nlsr& pnlsr);
+
 private:
 	uint32_t noLink;
 	Adl adl;
@@ -173,6 +177,8 @@
 	void setCorTheta(double ct){
 		corTheta=ct;
 	}
+
+	bool isLsaContentEqual(CorLsa& clsa);
 private:
 	double corRad;
 	double corTheta;
diff --git a/nlsr_lsdb.cpp b/nlsr_lsdb.cpp
index 3177fc8..da7d86e 100644
--- a/nlsr_lsdb.cpp
+++ b/nlsr_lsdb.cpp
@@ -57,7 +57,10 @@
 			std::list<string> nameList=nlsa.getNpl().getNameList();
 			for(std::list<string>::iterator it=nameList.begin(); it!=nameList.end();it++)
 			{
-				pnlsr.getNpt().addNpte((*it),nlsa.getOrigRouter(),pnlsr);
+				if ( (*it) !=pnlsr.getConfParameter().getRouterPrefix())
+				{
+					pnlsr.getNpt().addNpte((*it),nlsa.getOrigRouter(),pnlsr);
+				}
 			}
 		} 
 	}
@@ -83,7 +86,10 @@
       		chkNameLsa.first.addNameToLsa((*it));
       		if ( nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
       		{
-      			pnlsr.getNpt().addNpte((*it),nlsa.getOrigRouter(),pnlsr);
+      			if ( (*it) !=pnlsr.getConfParameter().getRouterPrefix())
+      			{
+      				pnlsr.getNpt().addNpte((*it),nlsa.getOrigRouter(),pnlsr);
+      			}
       		}
       }
                           
@@ -99,7 +105,10 @@
       		chkNameLsa.first.removeNameFromLsa((*it));
       		if ( nlsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
       		{
-      			pnlsr.getNpt().removeNpte((*it),nlsa.getOrigRouter(),pnlsr);
+      			if ( (*it) !=pnlsr.getConfParameter().getRouterPrefix())
+      			{
+      				pnlsr.getNpt().removeNpte((*it),nlsa.getOrigRouter(),pnlsr);
+      			}
       		}
       }  
 			
@@ -125,13 +134,26 @@
 }
 
 bool 
-Lsdb::removeNameLsa(string& key)
+Lsdb::removeNameLsa(nlsr& pnlsr, string& key)
 {
 	std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(), 
 																		nameLsdb.end(),	
    																	bind(nameLsaCompareByKey, _1, key));
   if ( it != nameLsdb.end() )
   {
+  		if ( (*it).getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix()  )
+  		{
+  			pnlsr.getNpt().removeNpte((*it).getOrigRouter(),(*it).getOrigRouter(),pnlsr);	
+  			for( std::list<string>::iterator nit=(*it).getNpl().getNameList().begin();
+  			                           nit!=(*it).getNpl().getNameList().end(); ++nit)
+  			{
+  				if ( (*nit) !=pnlsr.getConfParameter().getRouterPrefix())
+  				{
+  					pnlsr.getNpt().removeNpte((*nit),(*it).getOrigRouter(),pnlsr);
+  				}
+  			} 
+  			
+  		}
 		nameLsdb.erase(it);
 		return true;
   }
@@ -164,12 +186,8 @@
 }
 
 // Cor LSA and LSDB related Functions start here
-/*
-static bool
-corLsaCompare(CorLsa& clsa1, CorLsa& clsa2){
-	return clsa1.getLsaKey()==clsa1.getLsaKey();
-}
-*/
+
+
 static bool
 corLsaCompareByKey(CorLsa& clsa, string& key){
 	return clsa.getCorLsaKey()==key;
@@ -210,15 +228,12 @@
 	std::pair<CorLsa& , bool> chkCorLsa=getCorLsa(clsa.getCorLsaKey());
 	if ( !chkCorLsa.second )
 	{
-		// add cor LSA
 		addCorLsa(clsa);
 		printCorLsdb(); //debugging purpose
 		if ( clsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
 		{
 			pnlsr.getNpt().addNpte(clsa.getOrigRouter(),clsa.getOrigRouter(),pnlsr);
 		}
-		//schedule routing table calculation only if 
-		//hyperbolic calculation is scheduled
 		if (pnlsr.getConfParameter().getIsHyperbolicCalc() >=1 )
 		{
 			if ( pnlsr.getIsRouteCalculationScheduled() != 1 )
@@ -233,8 +248,28 @@
 	}
 	else
 	{
-		// check for newer cor LSA
-		//CorLsa oldCorLsa=getCorLsa(clsa.getCorLsaKey());
+		if ( chkCorLsa.first.getLsSeqNo() < clsa.getLsSeqNo() )
+		{
+			chkCorLsa.first.setLsSeqNo(clsa.getLsSeqNo());
+			chkCorLsa.first.setLifeTime(clsa.getLifeTime());
+			if ( !chkCorLsa.first.isLsaContentEqual(clsa) )
+			{
+				chkCorLsa.first.setCorRadius(clsa.getCorRadius());
+				chkCorLsa.first.setCorTheta(clsa.getCorTheta());
+
+				if (pnlsr.getConfParameter().getIsHyperbolicCalc() >=1 )
+				{
+					if ( pnlsr.getIsRouteCalculationScheduled() != 1 )
+					{
+						pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
+								ndn::bind(&RoutingTable::calculate, 
+								&pnlsr.getRoutingTable(),boost::ref(pnlsr)));
+						pnlsr.setIsRouteCalculationScheduled(1);
+					}	
+				}
+				
+			}
+		}
 		
 	}
 	
@@ -257,13 +292,17 @@
 }
 
 bool 
-Lsdb::removeCorLsa(string& key)
+Lsdb::removeCorLsa(nlsr& pnlsr, string& key)
 {
 	std::list<CorLsa >::iterator it = std::find_if( corLsdb.begin(), 
 																		corLsdb.end(),	
    																	bind(corLsaCompareByKey, _1, key));
   if ( it != corLsdb.end() )
   {
+  		if ( (*it).getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
+		{
+			pnlsr.getNpt().removeNpte((*it).getOrigRouter(),(*it).getOrigRouter(),pnlsr);
+		}
 		corLsdb.erase(it);
 		return true;
   }
@@ -329,7 +368,7 @@
 			{
 				//remove if there is any adj lsa in LSDB
 				string key=pnlsr.getConfParameter().getRouterPrefix()+"/2";
-				removeAdjLsa(key);
+				removeAdjLsa(pnlsr,key);
 				// Remove alll fib entries as per NPT
 			}
 			pnlsr.setAdjBuildCount(pnlsr.getAdjBuildCount()-adjBuildCount);
@@ -381,19 +420,11 @@
 bool 
 Lsdb::installAdjLsa(nlsr& pnlsr, AdjLsa &alsa)
 {
-	//bool doesLsaExist_ = doesAdjLsaExist(alsa.getAdjLsaKey());
-	//if ( !doesLsaExist_ )
 	std::pair<AdjLsa& , bool> chkAdjLsa=getAdjLsa(alsa.getAdjLsaKey());
 	if ( !chkAdjLsa.second )
 	{
-		// add Adj LSA
 		addAdjLsa(alsa);
-		// adding a NPT entry for router itself
-		if ( alsa.getOrigRouter() !=pnlsr.getConfParameter().getRouterPrefix() )
-		{
-			pnlsr.getNpt().addNpte(alsa.getOrigRouter(),alsa.getOrigRouter(),pnlsr);
-		}
-		// schedule routing table calculation
+		alsa.addNptEntriesForAdjLsa(pnlsr);
 		if ( pnlsr.getIsRouteCalculationScheduled() != 1 )
 		{
 			pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
@@ -404,8 +435,24 @@
 	}
 	else
 	{
-		// check for newer name LSA
-		//AdjLsa oldAdjLsa=getAdjLsa(alsa.getAdjLsaKey());
+		if ( chkAdjLsa.first.getLsSeqNo() < alsa.getLsSeqNo() )
+		{
+			chkAdjLsa.first.setLsSeqNo(alsa.getLsSeqNo());
+			chkAdjLsa.first.setLifeTime(alsa.getLifeTime());
+
+			if ( !	chkAdjLsa.first.isLsaContentEqual(alsa))
+			{
+				chkAdjLsa.first.getAdl().resetAdl();
+				chkAdjLsa.first.getAdl().addAdjacentsFromAdl(alsa.getAdl());
+				if ( pnlsr.getIsRouteCalculationScheduled() != 1 )
+				{
+					pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
+								ndn::bind(&RoutingTable::calculate, 
+								&pnlsr.getRoutingTable(),boost::ref(pnlsr)));
+					pnlsr.setIsRouteCalculationScheduled(1);
+				}	
+			}
+		}
 		
 	}
 
@@ -428,13 +475,14 @@
 }
 
 bool 
-Lsdb::removeAdjLsa(string& key)
+Lsdb::removeAdjLsa(nlsr& pnlsr, string& key)
 {
 	std::list<AdjLsa >::iterator it = std::find_if( adjLsdb.begin(), 
 																		adjLsdb.end(),	
    																	bind(adjLsaCompareByKey, _1, key));
   if ( it != adjLsdb.end() )
   {
+  		(*it).removeNptEntriesForAdjLsa(pnlsr);
 		adjLsdb.erase(it);
 		return true;
   }
@@ -462,6 +510,7 @@
 		return adjLsdb;
 }
 
+
 void 
 Lsdb::printAdjLsdb()
 {
diff --git a/nlsr_lsdb.hpp b/nlsr_lsdb.hpp
index 5d278ea..9ba0729 100644
--- a/nlsr_lsdb.hpp
+++ b/nlsr_lsdb.hpp
@@ -20,20 +20,20 @@
 	bool buildAndInstallOwnNameLsa(nlsr& pnlsr);
 	std::pair<NameLsa&, bool>  getNameLsa(string key);
 	bool installNameLsa(nlsr& pnlsr, NameLsa &nlsa);
-	bool removeNameLsa(string& key);
+	bool removeNameLsa(nlsr& pnlsr, string& key);
 	void printNameLsdb(); //debugging
 
 	//function related to Cor LSDB
 	bool buildAndInstallOwnCorLsa(nlsr& pnlsr);
 	std::pair<CorLsa&, bool> getCorLsa(string key);
 	bool installCorLsa(nlsr& pnlsr, CorLsa &clsa);
-	bool removeCorLsa(string& key);
+	bool removeCorLsa(nlsr& pnlsr, string& key);
 	void printCorLsdb(); //debugging
 
 	//function related to Adj LSDB
 	void scheduledAdjLsaBuild(nlsr& pnlsr);
 	bool buildAndInstallOwnAdjLsa(nlsr& pnlsr);
-	bool removeAdjLsa(string& key);
+	bool removeAdjLsa(nlsr& pnlsr, string& key);
 	bool installAdjLsa(nlsr& pnlsr, AdjLsa &alsa);
 	std::pair<AdjLsa& , bool> getAdjLsa(string key);
 	std::list<AdjLsa>& getAdjLsdb();
@@ -43,6 +43,7 @@
 	bool addNameLsa(NameLsa &nlsa);
 	bool doesNameLsaExist(string key);
 	
+	
 	bool addCorLsa(CorLsa& clsa);
 	bool doesCorLsaExist(string key);
 
