diff --git a/src/route/nlsr_npte.cpp b/src/route/nlsr_npte.cpp
index 60013ff..c342a21 100644
--- a/src/route/nlsr_npte.cpp
+++ b/src/route/nlsr_npte.cpp
@@ -7,77 +7,77 @@
 namespace nlsr
 {
 
-    using namespace std;
+  using namespace std;
 
-    void
-    Npte::generateNhlfromRteList()
+  void
+  Npte::generateNhlfromRteList()
+  {
+    nhl.resetNhl();
+    for( std::list<RoutingTableEntry>::iterator it=rteList.begin();
+         it != rteList.end(); ++it )
     {
-        nhl.resetNhl();
-        for( std::list<RoutingTableEntry>::iterator it=rteList.begin();
-                it != rteList.end(); ++it )
-        {
-            for(std::list< NextHop >::iterator nhit=(*it).getNhl().getNextHopList().begin();
-                    nhit != (*it).getNhl().getNextHopList().end(); ++nhit)
-            {
-                nhl.addNextHop((*nhit));
-            }
-        }
+      for(std::list< NextHop >::iterator nhit=(*it).getNhl().getNextHopList().begin();
+          nhit != (*it).getNhl().getNextHopList().end(); ++nhit)
+      {
+        nhl.addNextHop((*nhit));
+      }
     }
+  }
 
 
 
-    static bool
-    rteCompare(RoutingTableEntry& rte, string& destRouter)
+  static bool
+  rteCompare(RoutingTableEntry& rte, string& destRouter)
+  {
+    return rte.getDestination()==destRouter;
+  }
+
+  void
+  Npte::removeRoutingTableEntry(RoutingTableEntry& rte)
+  {
+    std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
+        rteList.end(),
+        bind(&rteCompare, _1, rte.getDestination()));
+    if ( it != rteList.end() )
     {
-        return rte.getDestination()==destRouter;
+      rteList.erase(it);
     }
+  }
 
-    void
-    Npte::removeRoutingTableEntry(RoutingTableEntry& rte)
+  void
+  Npte::addRoutingTableEntry(RoutingTableEntry &rte)
+  {
+    std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
+        rteList.end(),
+        bind(&rteCompare, _1, rte.getDestination()));
+    if ( it == rteList.end() )
     {
-        std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
-                rteList.end(),
-                bind(&rteCompare, _1, rte.getDestination()));
-        if ( it != rteList.end() )
-        {
-            rteList.erase(it);
-        }
+      rteList.push_back(rte);
     }
-
-    void
-    Npte::addRoutingTableEntry(RoutingTableEntry &rte)
+    else
     {
-        std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
-                rteList.end(),
-                bind(&rteCompare, _1, rte.getDestination()));
-        if ( it == rteList.end() )
-        {
-            rteList.push_back(rte);
-        }
-        else
-        {
-            (*it).getNhl().resetNhl(); // reseting existing routing table's next hop
-            for(std::list< NextHop >::iterator nhit=rte.getNhl().getNextHopList().begin();
-                    nhit != rte.getNhl().getNextHopList().end(); ++nhit)
-            {
-                (*it).getNhl().addNextHop((*nhit));
-            }
-        }
+      (*it).getNhl().resetNhl(); // reseting existing routing table's next hop
+      for(std::list< NextHop >::iterator nhit=rte.getNhl().getNextHopList().begin();
+          nhit != rte.getNhl().getNextHopList().end(); ++nhit)
+      {
+        (*it).getNhl().addNextHop((*nhit));
+      }
     }
+  }
 
 //debugging purpose
-    ostream&
-    operator<<(ostream& os, Npte& npte)
+  ostream&
+  operator<<(ostream& os, Npte& npte)
+  {
+    os<<"Name: "<<npte.getNamePrefix()<<endl;
+    std::list<RoutingTableEntry> rteList=npte.getRteList();
+    for(std::list<RoutingTableEntry >::iterator it=rteList.begin();
+        it !=rteList.end(); ++it)
     {
-        os<<"Name: "<<npte.getNamePrefix()<<endl;
-        std::list<RoutingTableEntry> rteList=npte.getRteList();
-        for(std::list<RoutingTableEntry >::iterator it=rteList.begin();
-                it !=rteList.end(); ++it)
-        {
-            cout<<(*it);
-        }
-        os<<npte.getNhl();
-        return os;
+      cout<<(*it);
     }
+    os<<npte.getNhl();
+    return os;
+  }
 
 }//namespace nlsr
