diff --git a/src/security/nlsr_km.cpp b/src/security/nlsr_km.cpp
index e97bbfe..8838878 100644
--- a/src/security/nlsr_km.cpp
+++ b/src/security/nlsr_km.cpp
@@ -7,306 +7,299 @@
 
 namespace nlsr
 {
-    bool
-    KeyManager::initKeyManager(ConfParameter &cp)
+  bool
+  KeyManager::initKeyManager(ConfParameter &cp)
+  {
+    initCertSeqFromFile(cp.getSeqFileDir());
+    if( !loadAllCertificates(cp.getCertDir()) )
     {
-        initCertSeqFromFile(cp.getSeqFileDir());
-        if( !loadAllCertificates(cp.getCertDir()) )
-        {
-            return false;
-        }
-        nlsrRootKeyPrefix=cp.getRootKeyPrefix();
-        string processIdentityName(cp.getRootKeyPrefix());
-        processIdentityName += "/";
-        processIdentityName += cp.getSiteName();
-        processIdentityName += "/";
-        processIdentityName += "R.Start";
-        processIdentityName += "/";
-        processIdentityName += cp.getRouterName();
-        ndn::Name ri(processIdentityName);
-        std::cout<<"Router Identity: "<<ri.toUri()<<std::endl;
-        routerIdentity=ri;
-        processIdentityName += "/";
-        processIdentityName += "nlsr";
-        cout<<"Proces Identity Name: "<<processIdentityName<<endl;
-        ndn::Name identityName(processIdentityName);
-        processIdentity=identityName;
-        ndn::KeyChain::deleteIdentity(processIdentity);
-        processCertName = ndn::KeyChain::createIdentity(processIdentity);
-        cout<<"Certificate Name: "<<processCertName.toUri()<<endl;
-        processKeyName=
-            ndn::IdentityCertificate::certificateNameToPublicKeyName(processCertName);
-        cout<<"Key Name: "<<processKeyName.toUri()<<endl;
-        ndn::shared_ptr<ndn::IdentityCertificate> cert=getCertificate(processCertName);
-        signByIdentity(*(cert),routerIdentity);
-        //initCertSeqFromFile(cp.getSeqFileDir());
-        certStore.addCertificate(cert, certSeqNo, true);
-        certStore.printCertStore();
-        
-        return true;
+      return false;
     }
-    
-    bool 
-    KeyManager::loadAllCertificates(std::string certDirPath)
-    {
-        std::string filePath=certDirPath;
-        if(filePath.empty())
-        {
-            SequencingManager sm;
-            filePath=sm.getUserHomeDirectory();
-            filePath+="/nlsrCertDir";
-        }
-        
-        return loadCertificate(filePath+"/root.cert", KEY_TYPE_ROOT) 
-               && loadCertificate(filePath+"/site.cert", KEY_TYPE_SITE)
-               && loadCertificate(filePath+"/operator.cert", KEY_TYPE_OPERATOR)
-               && loadCertificate(filePath+"/router.cert", KEY_TYPE_ROUTER) ;
-    }
-    
-    bool 
-    KeyManager::loadCertificate(std::string inputFile, nlsrKeyType keyType)
-    {
-        try
-        {
-            ndn::shared_ptr<ndn::IdentityCertificate> cert = 
-             ndn::io::load<ndn::IdentityCertificate>(inputFile, ndn::io::BASE_64);
-            ndn::Name certName=cert->getName();
-            //certStore.addCertificate(cert, 10, true);
-            switch(keyType)
-            {
-                case KEY_TYPE_ROOT:
-                    certStore.addCertificate(cert, 10, true);
-                    rootCertName=certName;
-                    break;
-                case KEY_TYPE_SITE:
-                    certStore.addCertificate(cert, 10, true);
-                    siteCertName=certName;
-                    break;
-                case KEY_TYPE_OPERATOR:
-                    certStore.addCertificate(cert, 10, true);
-                    opCertName=certName;
-                    break;
-                case KEY_TYPE_ROUTER:
-                    certStore.addCertificate(cert, certSeqNo, true);
-                    routerCertName=certName;
-                    break;
-                case KEY_TYPE_PROCESS:
-                    certStore.addCertificate(cert, certSeqNo, true);
-                    processCertName=certName;
-                    break;
-                default:
-                    break;
-            }
-            return true;
-        }
-        catch(std::exception& e)
-        {
-            return false;
-        }
-        
-        return false;
-    }
+    nlsrRootKeyPrefix=cp.getRootKeyPrefix();
+    string processIdentityName(cp.getRootKeyPrefix());
+    processIdentityName += "/";
+    processIdentityName += cp.getSiteName();
+    processIdentityName += "/";
+    processIdentityName += "R.Start";
+    processIdentityName += "/";
+    processIdentityName += cp.getRouterName();
+    ndn::Name ri(processIdentityName);
+    std::cout<<"Router Identity: "<<ri.toUri()<<std::endl;
+    routerIdentity=ri;
+    processIdentityName += "/";
+    processIdentityName += "nlsr";
+    cout<<"Proces Identity Name: "<<processIdentityName<<endl;
+    ndn::Name identityName(processIdentityName);
+    processIdentity=identityName;
+    ndn::KeyChain::deleteIdentity(processIdentity);
+    processCertName = ndn::KeyChain::createIdentity(processIdentity);
+    cout<<"Certificate Name: "<<processCertName.toUri()<<endl;
+    processKeyName=
+      ndn::IdentityCertificate::certificateNameToPublicKeyName(processCertName);
+    cout<<"Key Name: "<<processKeyName.toUri()<<endl;
+    ndn::shared_ptr<ndn::IdentityCertificate> cert=getCertificate(processCertName);
+    signByIdentity(*(cert),routerIdentity);
+    certStore.addCertificate(cert, certSeqNo, true);
+    //certStore.printCertStore();
+    return true;
+  }
 
-    ndn::Name
-    KeyManager::getProcessCertName()
+  bool
+  KeyManager::loadAllCertificates(std::string certDirPath)
+  {
+    std::string filePath=certDirPath;
+    if(filePath.empty())
     {
-        return processCertName;
+      SequencingManager sm;
+      filePath=sm.getUserHomeDirectory();
+      filePath+="/nlsrCertDir";
     }
-    
-    ndn::Name 
-    KeyManager::getRouterCertName()
-    {
-        return routerCertName;
-    }
-    
-    ndn::Name 
-    KeyManager::getOperatorCertName()
-    {
-        return opCertName;
-    }
-    
-    ndn::Name 
-    KeyManager::getSiteCertName()
-    {
-        return siteCertName;
-    }
-    
-    ndn::Name 
-    KeyManager::getRootCertName()
-    {
-        return rootCertName;
-    }
+    return loadCertificate(filePath+"/root.cert", KEY_TYPE_ROOT)
+           && loadCertificate(filePath+"/site.cert", KEY_TYPE_SITE)
+           && loadCertificate(filePath+"/operator.cert", KEY_TYPE_OPERATOR)
+           && loadCertificate(filePath+"/router.cert", KEY_TYPE_ROUTER) ;
+  }
 
-    uint32_t
-    KeyManager::getCertSeqNo()
+  bool
+  KeyManager::loadCertificate(std::string inputFile, nlsrKeyType keyType)
+  {
+    try
     {
-        return certSeqNo;
+      ndn::shared_ptr<ndn::IdentityCertificate> cert =
+        ndn::io::load<ndn::IdentityCertificate>(inputFile, ndn::io::BASE_64);
+      ndn::Name certName=cert->getName();
+      switch(keyType)
+      {
+        case KEY_TYPE_ROOT:
+          certStore.addCertificate(cert, 10, true);
+          rootCertName=certName;
+          break;
+        case KEY_TYPE_SITE:
+          certStore.addCertificate(cert, 10, true);
+          siteCertName=certName;
+          break;
+        case KEY_TYPE_OPERATOR:
+          certStore.addCertificate(cert, 10, true);
+          opCertName=certName;
+          break;
+        case KEY_TYPE_ROUTER:
+          certStore.addCertificate(cert, certSeqNo, true);
+          routerCertName=certName;
+          break;
+        case KEY_TYPE_PROCESS:
+          certStore.addCertificate(cert, certSeqNo, true);
+          processCertName=certName;
+          break;
+        default:
+          break;
+      }
+      return true;
     }
+    catch(std::exception& e)
+    {
+      return false;
+    }
+    return false;
+  }
 
-    void
-    KeyManager::setCerSeqNo(uint32_t csn)
-    {
-        certSeqNo=csn;
-    }
+  ndn::Name
+  KeyManager::getProcessCertName()
+  {
+    return processCertName;
+  }
 
-    void
-    KeyManager::initCertSeqFromFile(string certSeqFileDir)
-    {
-        certSeqFileNameWithPath=certSeqFileDir;
-        if( certSeqFileNameWithPath.empty() )
-        {
-            SequencingManager sm;
-            certSeqFileNameWithPath=sm.getUserHomeDirectory();
-        }
-        certSeqFileNameWithPath += "/nlsrCertSeqNo.txt";
-        cout<<"Key Seq File Name: "<< certSeqFileNameWithPath<<endl;
-        std::ifstream inputFile(certSeqFileNameWithPath.c_str(),ios::binary);
-        if ( inputFile.good() )
-        {
-            inputFile>>certSeqNo;
-            certSeqNo++;
-        }
-        else
-        {
-            certSeqNo=1;
-        }
-        writeCertSeqToFile();
-    }
+  ndn::Name
+  KeyManager::getRouterCertName()
+  {
+    return routerCertName;
+  }
 
-    void
-    KeyManager::writeCertSeqToFile()
+  ndn::Name
+  KeyManager::getOperatorCertName()
+  {
+    return opCertName;
+  }
+
+  ndn::Name
+  KeyManager::getSiteCertName()
+  {
+    return siteCertName;
+  }
+
+  ndn::Name
+  KeyManager::getRootCertName()
+  {
+    return rootCertName;
+  }
+
+  uint32_t
+  KeyManager::getCertSeqNo()
+  {
+    return certSeqNo;
+  }
+
+  void
+  KeyManager::setCerSeqNo(uint32_t csn)
+  {
+    certSeqNo=csn;
+  }
+
+  void
+  KeyManager::initCertSeqFromFile(string certSeqFileDir)
+  {
+    certSeqFileNameWithPath=certSeqFileDir;
+    if( certSeqFileNameWithPath.empty() )
     {
-        std::ofstream outputFile(certSeqFileNameWithPath.c_str(),ios::binary);
-        outputFile<<certSeqNo;
-        outputFile.close();
+      SequencingManager sm;
+      certSeqFileNameWithPath=sm.getUserHomeDirectory();
     }
-    
-    bool 
-    KeyManager::isNewCertificate(std::string certName, int checkSeqNum)
+    certSeqFileNameWithPath += "/nlsrCertSeqNo.txt";
+    cout<<"Key Seq File Name: "<< certSeqFileNameWithPath<<endl;
+    std::ifstream inputFile(certSeqFileNameWithPath.c_str(),ios::binary);
+    if ( inputFile.good() )
     {
-        return certStore.isCertificateNewInStore(certName,checkSeqNum);
+      inputFile>>certSeqNo;
+      certSeqNo++;
     }
-    
-    std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
-    KeyManager::getCertificateFromStore(const std::string certName, int checkSeqNum)
+    else
     {
-        return certStore.getCertificateFromStore(certName, checkSeqNum);
+      certSeqNo=1;
     }
-    
-    bool 
-    KeyManager::addCertificate(ndn::shared_ptr<ndn::IdentityCertificate> pcert
-                                                      , uint32_t csn, bool isv)
+    writeCertSeqToFile();
+  }
+
+  void
+  KeyManager::writeCertSeqToFile()
+  {
+    std::ofstream outputFile(certSeqFileNameWithPath.c_str(),ios::binary);
+    outputFile<<certSeqNo;
+    outputFile.close();
+  }
+
+  bool
+  KeyManager::isNewCertificate(std::string certName, int checkSeqNum)
+  {
+    return certStore.isCertificateNewInStore(certName,checkSeqNum);
+  }
+
+  std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool>
+  KeyManager::getCertificateFromStore(const std::string certName, int checkSeqNum)
+  {
+    return certStore.getCertificateFromStore(certName, checkSeqNum);
+  }
+
+  bool
+  KeyManager::addCertificate(ndn::shared_ptr<ndn::IdentityCertificate> pcert
+                             , uint32_t csn, bool isv)
+  {
+    return certStore.addCertificate(pcert, csn, isv);
+  }
+
+  nlsrKeyType
+  KeyManager::getKeyTypeFromName(const std::string keyName)
+  {
+    nlsrTokenizer nt(keyName,"/");
+    std::string KEY("KEY");
+    std::string opHandle("O.Start");
+    std::string routerHandle("R.Start");
+    std::string processHandle("nlsr");
+    if ( nt.getTokenString(0,nt.getTokenPosition(KEY)-1) == nlsrRootKeyPrefix)
     {
-        return certStore.addCertificate(pcert, csn, isv);
+      return KEY_TYPE_ROOT;
     }
-    
-    nlsrKeyType 
-    KeyManager::getKeyTypeFromName(const std::string keyName)
+    else if ( nt.doesTokenExist(opHandle) )
     {
-        nlsrTokenizer nt(keyName,"/");
-        std::string KEY("KEY");
-        std::string opHandle("O.Start");
-        std::string routerHandle("R.Start");
-        std::string processHandle("nlsr");
-        if ( nt.getTokenString(0,nt.getTokenPosition(KEY)-1) == nlsrRootKeyPrefix)
-        {
-            return KEY_TYPE_ROOT;
-        }
-        else if ( nt.doesTokenExist(opHandle) )
-        {
-            return KEY_TYPE_OPERATOR;
-        }
-        else if ( nt.doesTokenExist(routerHandle) && 
-                                             nt.doesTokenExist(processHandle))
-        {
-            return KEY_TYPE_PROCESS;
-        }
-        else if ( nt.doesTokenExist(routerHandle) && 
-                                             !nt.doesTokenExist(processHandle))
-        {
-            return KEY_TYPE_ROUTER;
-        }
-        else
-        {
-            return KEY_TYPE_SITE;
-        }
+      return KEY_TYPE_OPERATOR;
     }
-    
-    std::string 
-    KeyManager::getRouterName(const std::string name)
+    else if ( nt.doesTokenExist(routerHandle) &&
+              nt.doesTokenExist(processHandle))
     {
-        std::string routerName;
-        std::string rkp(nlsrRootKeyPrefix);
-        nlsrTokenizer ntRkp(rkp,"/");
-        nlsrTokenizer nt(name,"/");
-        std::string KEY("KEY");
-        std::string opHandle("O.Start");
-        std::string routerHandle("R.Start");
-        std::string processHandle("nlsr");
-        std::string infoHandle("info");
-        std::string lsaHandle("LSA");
-        
-        if ( nt.doesTokenExist(processHandle) && nt.doesTokenExist(routerHandle))
-        {
-            routerName="/ndn" + 
-                        nt.getTokenString(ntRkp.getTokenNumber(), 
-                                          nt.getTokenPosition(routerHandle)-1) +
-                        nt.getTokenString(nt.getTokenPosition(routerHandle)+1, 
-                                          nt.getTokenPosition(processHandle)-1);
-        }
-        else if(nt.doesTokenExist(routerHandle) && !nt.doesTokenExist(infoHandle)
-                                                && !nt.doesTokenExist(lsaHandle))
-        {
-            routerName="/ndn" + 
-                        nt.getTokenString(ntRkp.getTokenNumber(), 
-                                          nt.getTokenPosition(routerHandle)-1) +
-                        nt.getTokenString(nt.getTokenPosition(routerHandle)+1,
-                                                    nt.getTokenPosition(KEY)-1);
-        }
-        else
-        {
-            if (nt.doesTokenExist(infoHandle) )
-            {
-               routerName=nt.getTokenString(0,nt.getTokenPosition(infoHandle)-1);
-            }
-            else
-            {
-                routerName=nt.getTokenString(nt.getTokenPosition(lsaHandle)+1,
-                                             nt.getTokenNumber()-3);
-            } 
-        }
-        return routerName;
+      return KEY_TYPE_PROCESS;
     }
-        
-    std::string 
-    KeyManager::getSiteName(const std::string name)
+    else if ( nt.doesTokenExist(routerHandle) &&
+              !nt.doesTokenExist(processHandle))
     {
-        std::string siteName;
-        std::string routerName;
-        std::string rkp(nlsrRootKeyPrefix);
-        nlsrTokenizer ntRkp(rkp,"/");
-        nlsrTokenizer nt(name,"/");
-        std::string KEY("KEY");
-        std::string opHandle("O.Start");
-        std::string routerHandle("R.Start");
-        
-        if ( nt.doesTokenExist(routerHandle) )
-        {
-            siteName="/ndn" + nt.getTokenString(ntRkp.getTokenNumber(), 
-                                          nt.getTokenPosition(routerHandle) -1); 
-        }
-        else if ( nt.doesTokenExist(opHandle) )
-        {
-            siteName="/ndn" + nt.getTokenString(ntRkp.getTokenNumber(), 
+      return KEY_TYPE_ROUTER;
+    }
+    else
+    {
+      return KEY_TYPE_SITE;
+    }
+  }
+
+  std::string
+  KeyManager::getRouterName(const std::string name)
+  {
+    std::string routerName;
+    std::string rkp(nlsrRootKeyPrefix);
+    nlsrTokenizer ntRkp(rkp,"/");
+    nlsrTokenizer nt(name,"/");
+    std::string KEY("KEY");
+    std::string opHandle("O.Start");
+    std::string routerHandle("R.Start");
+    std::string processHandle("nlsr");
+    std::string infoHandle("info");
+    std::string lsaHandle("LSA");
+    if ( nt.doesTokenExist(processHandle) && nt.doesTokenExist(routerHandle))
+    {
+      routerName="/ndn" +
+                 nt.getTokenString(ntRkp.getTokenNumber(),
+                                   nt.getTokenPosition(routerHandle)-1) +
+                 nt.getTokenString(nt.getTokenPosition(routerHandle)+1,
+                                   nt.getTokenPosition(processHandle)-1);
+    }
+    else if(nt.doesTokenExist(routerHandle) && !nt.doesTokenExist(infoHandle)
+            && !nt.doesTokenExist(lsaHandle))
+    {
+      routerName="/ndn" +
+                 nt.getTokenString(ntRkp.getTokenNumber(),
+                                   nt.getTokenPosition(routerHandle)-1) +
+                 nt.getTokenString(nt.getTokenPosition(routerHandle)+1,
+                                   nt.getTokenPosition(KEY)-1);
+    }
+    else
+    {
+      if (nt.doesTokenExist(infoHandle) )
+      {
+        routerName=nt.getTokenString(0,nt.getTokenPosition(infoHandle)-1);
+      }
+      else
+      {
+        routerName=nt.getTokenString(nt.getTokenPosition(lsaHandle)+1,
+                                     nt.getTokenNumber()-4);
+      }
+    }
+    return routerName;
+  }
+
+  std::string
+  KeyManager::getSiteName(const std::string name)
+  {
+    std::string siteName;
+    std::string routerName;
+    std::string rkp(nlsrRootKeyPrefix);
+    nlsrTokenizer ntRkp(rkp,"/");
+    nlsrTokenizer nt(name,"/");
+    std::string KEY("KEY");
+    std::string opHandle("O.Start");
+    std::string routerHandle("R.Start");
+    if ( nt.doesTokenExist(routerHandle) )
+    {
+      siteName="/ndn" + nt.getTokenString(ntRkp.getTokenNumber(),
+                                          nt.getTokenPosition(routerHandle) -1);
+    }
+    else if ( nt.doesTokenExist(opHandle) )
+    {
+      siteName="/ndn" + nt.getTokenString(ntRkp.getTokenNumber(),
                                           nt.getTokenPosition(opHandle) -1);
-        }
-        else
-        {
-           siteName="/ndn" + nt.getTokenString(ntRkp.getTokenNumber(), 
-                                          nt.getTokenPosition(KEY) -1); 
-        }
-        return siteName;
     }
+    else
+    {
+      siteName="/ndn" + nt.getTokenString(ntRkp.getTokenNumber(),
+                                          nt.getTokenPosition(KEY) -1);
+    }
+    return siteName;
+  }
 }
 
 
