diff --git a/src/nlsr_nhl.cpp b/src/nlsr_nhl.cpp
index c23cc04..2aaa2a6 100644
--- a/src/nlsr_nhl.cpp
+++ b/src/nlsr_nhl.cpp
@@ -3,83 +3,88 @@
 #include "nlsr_nhl.hpp"
 #include "nlsr_nexthop.hpp"
 
-namespace nlsr {
-
-using namespace std;
-
-static bool
-nexthopCompare(NextHop& nh1, NextHop& nh2){
-	return nh1.getConnectingFace()==nh2.getConnectingFace();
-}
-
-static bool
-nexthopRemoveCompare(NextHop& nh1, NextHop& nh2){
-	return (nh1.getConnectingFace()==nh2.getConnectingFace() && 
-	       nh1.getRouteCost() == nh2.getRouteCost()) ;
-}
-
-static bool
-nextHopSortingComparator(NextHop& nh1, NextHop& nh2)
+namespace nlsr
 {
-	return nh1.getRouteCost() < nh2.getRouteCost();
-}
 
-/** 
-Add next hop to the Next Hop list
-If next hop is new it is added
-If next hop already exists in next
-hop list then updates the route
-cost with new next hop's route cost
-*/
+    using namespace std;
 
-void
-Nhl::addNextHop(NextHop& nh)
-{
-	std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(), 
-									nexthopList.end(),	
-   								bind(&nexthopCompare, _1, nh));
-	if ( it == nexthopList.end() ){
-		nexthopList.push_back(nh);
-	}
-	if ( (*it).getRouteCost() > nh.getRouteCost() )
-	{
-		(*it).setRouteCost(nh.getRouteCost());
-	}
-}
+    static bool
+    nexthopCompare(NextHop& nh1, NextHop& nh2)
+    {
+        return nh1.getConnectingFace()==nh2.getConnectingFace();
+    }
 
-/**
-Remove a next hop only if both next hop face and route cost are same
+    static bool
+    nexthopRemoveCompare(NextHop& nh1, NextHop& nh2)
+    {
+        return (nh1.getConnectingFace()==nh2.getConnectingFace() &&
+                nh1.getRouteCost() == nh2.getRouteCost()) ;
+    }
 
-*/
+    static bool
+    nextHopSortingComparator(NextHop& nh1, NextHop& nh2)
+    {
+        return nh1.getRouteCost() < nh2.getRouteCost();
+    }
 
-void 
-Nhl::removeNextHop(NextHop &nh)
-{
-	std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(), 
-									nexthopList.end(),	
-   								bind(&nexthopRemoveCompare, _1, nh));
-  if ( it != nexthopList.end() ){
-		nexthopList.erase(it);
-	}
-}
+    /**
+    Add next hop to the Next Hop list
+    If next hop is new it is added
+    If next hop already exists in next
+    hop list then updates the route
+    cost with new next hop's route cost
+    */
 
-void
-Nhl::sortNhl()
-{
-	nexthopList.sort(nextHopSortingComparator);
-}
+    void
+    Nhl::addNextHop(NextHop& nh)
+    {
+        std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(),
+                                           nexthopList.end(),
+                                           bind(&nexthopCompare, _1, nh));
+        if ( it == nexthopList.end() )
+        {
+            nexthopList.push_back(nh);
+        }
+        if ( (*it).getRouteCost() > nh.getRouteCost() )
+        {
+            (*it).setRouteCost(nh.getRouteCost());
+        }
+    }
 
-ostream&
-operator<<(ostream& os, Nhl& nhl)
-{
-	std::list< NextHop > nexthopList = nhl.getNextHopList();
-	int i=1;
-	for( std::list<NextHop>::iterator it=nexthopList.begin(); 
-	                                            it!= nexthopList.end() ; it++,i++)
-	{
-		os << "Nexthop "<<i<<": "<<(*it)<<endl;
-	}
-	return os;
-}
+    /**
+    Remove a next hop only if both next hop face and route cost are same
+
+    */
+
+    void
+    Nhl::removeNextHop(NextHop &nh)
+    {
+        std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(),
+                                           nexthopList.end(),
+                                           bind(&nexthopRemoveCompare, _1, nh));
+        if ( it != nexthopList.end() )
+        {
+            nexthopList.erase(it);
+        }
+    }
+
+    void
+    Nhl::sortNhl()
+    {
+        nexthopList.sort(nextHopSortingComparator);
+    }
+
+    ostream&
+    operator<<(ostream& os, Nhl& nhl)
+    {
+        std::list< NextHop > nexthopList = nhl.getNextHopList();
+        int i=1;
+        for( std::list<NextHop>::iterator it=nexthopList.begin();
+                it!= nexthopList.end() ; it++,i++)
+        {
+            os << "Nexthop "<<i<<": "<<(*it)<<endl;
+        }
+        return os;
+    }
 
 }//namespace nlsr
