diff --git a/src/route/nlsr_npt.cpp b/src/route/nlsr_npt.cpp
index 9c4d4cb..2dfa311 100644
--- a/src/route/nlsr_npt.cpp
+++ b/src/route/nlsr_npt.cpp
@@ -9,134 +9,141 @@
 namespace nlsr
 {
 
-    using namespace std;
+  using namespace std;
 
-    static bool
-    npteCompare(Npte& npte, string& name)
+  static bool
+  npteCompare(Npte& npte, string& name)
+  {
+    return npte.getNamePrefix()==name;
+  }
+
+
+
+  void
+  Npt::addNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr)
+  {
+    std::list<Npte >::iterator it = std::find_if( npteList.begin(),
+                                    npteList.end(), bind(&npteCompare, _1, name));
+    if ( it == npteList.end() )
     {
-        return npte.getNamePrefix()==name;
+      Npte newEntry(name);
+      newEntry.addRoutingTableEntry(rte);
+      newEntry.generateNhlfromRteList();
+      newEntry.getNhl().sortNhl();
+      npteList.push_back(newEntry);
+      if(rte.getNhl().getNhlSize()> 0)
+      {
+        pnlsr.getFib().updateFib(pnlsr, name,newEntry.getNhl());
+      }
     }
-
-// Following two methods will update FIB with response to change in NPT
-
-    void
-    Npt::addNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr)
+    else
     {
-        std::list<Npte >::iterator it = std::find_if( npteList.begin(),
-                                        npteList.end(), bind(&npteCompare, _1, name));
-        if ( it == npteList.end() )
-        {
-            Npte newEntry(	name);
-            newEntry.addRoutingTableEntry(rte);
-            newEntry.generateNhlfromRteList();
-            npteList.push_back(newEntry);
-            // update FIB here with nhl list newEntry.getNhl()
-            pnlsr.getFib().updateFib(pnlsr, name,newEntry.getNhl(),
-                                     pnlsr.getConfParameter().getMaxFacesPerPrefix());
-        }
-        else
-        {
-            (*it).addRoutingTableEntry(rte);
-            (*it).generateNhlfromRteList();
-            // update FIB here with nhl list from (*it).getNhl()
-            pnlsr.getFib().updateFib(pnlsr, name,(*it).getNhl() ,
-                                     pnlsr.getConfParameter().getMaxFacesPerPrefix());
-        }
+      if ( rte.getNhl().getNhlSize()> 0 )
+      {
+        (*it).addRoutingTableEntry(rte);
+        (*it).generateNhlfromRteList();
+        (*it).getNhl().sortNhl();
+        pnlsr.getFib().updateFib(pnlsr, name,(*it).getNhl());
+      }
+      else
+      {
+        (*it).resetRteListNextHop();
+        (*it).getNhl().resetNhl();
+        pnlsr.getFib().removeFromFib(pnlsr,name);
+      }
     }
+  }
 
-    void
-    Npt::removeNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr)
+  void
+  Npt::removeNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr)
+  {
+    std::list<Npte >::iterator it = std::find_if( npteList.begin(),
+                                    npteList.end(), bind(&npteCompare, _1, name));
+    if ( it != npteList.end() )
     {
-        std::list<Npte >::iterator it = std::find_if( npteList.begin(),
-                                        npteList.end(), bind(&npteCompare, _1, name));
-        if ( it != npteList.end() )
-        {
-            string destRouter=rte.getDestination();
-            (*it).removeRoutingTableEntry(rte);
-            if ( ((*it).getRteListSize() == 0 ) &&
-                    (!pnlsr.getLsdb().doesLsaExist(destRouter+"/1",1) ) &&
-                    (!pnlsr.getLsdb().doesLsaExist(destRouter+"/2",2) ) &&
-                    (!pnlsr.getLsdb().doesLsaExist(destRouter+"/3",3) )   )
-            {
-                npteList.erase(it); // remove entry from NPT
-                // remove FIB entry with this name
-                pnlsr.getFib().removeFromFib(pnlsr,name);
-            }
-            else
-            {
-                (*it).generateNhlfromRteList();
-                // update FIB entry with new NHL
-                pnlsr.getFib().updateFib(pnlsr, name,(*it).getNhl(),
-                                         pnlsr.getConfParameter().getMaxFacesPerPrefix());
-            }
-        }
+      string destRouter=rte.getDestination();
+      (*it).removeRoutingTableEntry(rte);
+      if ( ((*it).getRteListSize() == 0 ) &&
+           (!pnlsr.getLsdb().doesLsaExist(destRouter+"/1",1) ) &&
+           (!pnlsr.getLsdb().doesLsaExist(destRouter+"/2",2) ) &&
+           (!pnlsr.getLsdb().doesLsaExist(destRouter+"/3",3) )   )
+      {
+        npteList.erase(it);
+        pnlsr.getFib().removeFromFib(pnlsr,name);
+      }
+      else
+      {
+        (*it).generateNhlfromRteList();
+        pnlsr.getFib().updateFib(pnlsr, name,(*it).getNhl());
+      }
     }
+  }
 
 
-    void
-    Npt::addNpte(string name, string destRouter, Nlsr& pnlsr)
+  void
+  Npt::addNpteByDestName(string name, string destRouter, Nlsr& pnlsr)
+  {
+    std::pair<RoutingTableEntry& , bool> rteCheck=
+      pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
+    if(rteCheck.second)
     {
+      addNpte(name,rteCheck.first,pnlsr);
+    }
+    else
+    {
+      RoutingTableEntry rte(destRouter);
+      addNpte(name, rte,pnlsr);
+    }
+  }
+
+  void
+  Npt::removeNpte(string name, string destRouter, Nlsr& pnlsr)
+  {
+    std::pair<RoutingTableEntry& , bool> rteCheck=
+      pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
+    if(rteCheck.second)
+    {
+      removeNpte(name,rteCheck.first,pnlsr);
+    }
+    else
+    {
+      RoutingTableEntry rte(destRouter);
+      removeNpte(name, rte,pnlsr);
+    }
+  }
+
+  void
+  Npt::updateNptWithNewRoute(Nlsr& pnlsr)
+  {
+    for(std::list<Npte >::iterator it=npteList.begin(); it!=npteList.end(); ++it)
+    {
+      std::list<RoutingTableEntry> rteList=(*it).getRteList();
+      for(std::list<RoutingTableEntry >::iterator rteit=rteList.begin();
+          rteit !=rteList.end(); ++rteit)
+      {
         std::pair<RoutingTableEntry& , bool> rteCheck=
-            pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
+          pnlsr.getRoutingTable().findRoutingTableEntry((*rteit).getDestination());
         if(rteCheck.second)
         {
-            addNpte(name,rteCheck.first,pnlsr);
+          addNpte((*it).getNamePrefix(),rteCheck.first,pnlsr);
         }
         else
         {
-            RoutingTableEntry rte(destRouter);
-            addNpte(name, rte,pnlsr);
+          RoutingTableEntry rte((*rteit).getDestination());
+          addNpte((*it).getNamePrefix(), rte,pnlsr);
         }
+      }
     }
+  }
 
-    void
-    Npt::removeNpte(string name, string destRouter, Nlsr& pnlsr)
+  void
+  Npt::printNpt()
+  {
+    cout<<"----------------NPT----------------------"<<endl;
+    for(std::list<Npte >::iterator it=npteList.begin(); it!=npteList.end(); ++it)
     {
-        std::pair<RoutingTableEntry& , bool> rteCheck=
-            pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
-        if(rteCheck.second)
-        {
-            removeNpte(name,rteCheck.first,pnlsr);
-        }
-        else
-        {
-            RoutingTableEntry rte(destRouter);
-            removeNpte(name, rte,pnlsr);
-        }
+      cout <<(*it)<<endl;
     }
-
-    void
-    Npt::updateNptWithNewRoute(Nlsr& pnlsr)
-    {
-        for(std::list<Npte >::iterator it=npteList.begin(); it!=npteList.end(); ++it)
-        {
-            std::list<RoutingTableEntry> rteList=(*it).getRteList();
-            for(std::list<RoutingTableEntry >::iterator rteit=rteList.begin();
-                    rteit !=rteList.end(); ++rteit)
-            {
-                std::pair<RoutingTableEntry& , bool> rteCheck=
-                    pnlsr.getRoutingTable().findRoutingTableEntry((*rteit).getDestination());
-                if(rteCheck.second)
-                {
-                    addNpte((*it).getNamePrefix(),rteCheck.first,pnlsr);
-                }
-                else
-                {
-                    RoutingTableEntry rte((*rteit).getDestination());
-                    addNpte((*it).getNamePrefix(), rte,pnlsr);
-                }
-            }
-        }
-    }
-
-    void
-    Npt::printNpt()
-    {
-        cout<<"----------------NPT----------------------"<<endl;
-        for(std::list<Npte >::iterator it=npteList.begin(); it!=npteList.end(); ++it)
-        {
-            cout <<(*it)<<endl;
-        }
-    }
+  }
 
 }
