diff --git a/src/profile.cpp b/src/profile.cpp
index e6044fa..cd69849 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -8,15 +8,18 @@
  * Author: Yingdi Yu <yingdi@cs.ucla.edu>
  */
 
-#include "profile.h"
+#include "profile.hpp"
 #include "logging.h"
 
-using namespace ndn;
-
-INIT_LOGGER("Profile");
-
 namespace chronos{
 
+using std::vector;
+using std::string;
+using std::map;
+
+using ndn::IdentityCertificate;
+using ndn::CertificateSubjectDescription;
+
 const std::string Profile::OID_NAME("2.5.4.41");
 const std::string Profile::OID_ORG("2.5.4.11");
 const std::string Profile::OID_GROUP("2.5.4.1");
@@ -28,29 +31,30 @@
 {
   Name keyName = IdentityCertificate::certificateNameToPublicKeyName(identityCertificate.getName());
 
-  m_entries[std::string("IDENTITY")] = keyName.getPrefix(-1).toUri();
+  m_entries[string("IDENTITY")] = keyName.getPrefix(-1).toUri();
 
-  const std::vector<CertificateSubjectDescription>& subList = identityCertificate.getSubjectDescriptionList();
-  std::vector<CertificateSubjectDescription>::const_iterator it = subList.begin();
-  for(; it != subList.end(); it++)
-    {
-      const std::string oidStr = it->getOidString();
-      std::string valueStr = it->getValue();
-      if(oidStr == OID_NAME)
-        m_entries["name"] = valueStr;
-      else if(oidStr == OID_ORG)
-        m_entries["institution"] = valueStr;
-      else if(oidStr == OID_GROUP)
-        m_entries["group"] = valueStr;
-      else if(oidStr == OID_HOMEPAGE)
-        m_entries["homepage"] = valueStr;
-      else if(oidStr == OID_ADVISOR)
-        m_entries["advisor"] = valueStr;
-      else if(oidStr == OID_EMAIL)
-        m_entries["email"] = valueStr;
-      else
-        m_entries[oidStr] = valueStr;
-    }
+  const vector<CertificateSubjectDescription>& subList =
+    identityCertificate.getSubjectDescriptionList();
+
+  for (vector<CertificateSubjectDescription>::const_iterator it = subList.begin();
+       it != subList.end(); it++) {
+    const string oidStr = it->getOidString();
+    string valueStr = it->getValue();
+    if (oidStr == OID_NAME)
+      m_entries["name"] = valueStr;
+    else if (oidStr == OID_ORG)
+      m_entries["institution"] = valueStr;
+    else if (oidStr == OID_GROUP)
+      m_entries["group"] = valueStr;
+    else if (oidStr == OID_HOMEPAGE)
+      m_entries["homepage"] = valueStr;
+    else if (oidStr == OID_ADVISOR)
+      m_entries["advisor"] = valueStr;
+    else if (oidStr == OID_EMAIL)
+      m_entries["email"] = valueStr;
+    else
+      m_entries[oidStr] = valueStr;
+  }
 }
 
 Profile::Profile(const Name& identityName)
@@ -59,8 +63,8 @@
 }
 
 Profile::Profile(const Name& identityName,
-                 const std::string& name,
-                 const std::string& institution)
+                 const string& name,
+                 const string& institution)
 {
   m_entries["IDENTITY"] = identityName.toUri();
   m_entries["name"] = name;
@@ -69,7 +73,8 @@
 
 Profile::Profile(const Profile& profile)
   : m_entries(profile.m_entries)
-{}
+{
+}
 
 void
 Profile::encode(std::ostream& os) const
@@ -87,29 +92,50 @@
   profileMsg >> (*this);
 }
 
-Chronos::ProfileMsg&
-operator << (Chronos::ProfileMsg& profileMsg, const Profile& profile)
+bool
+Profile::operator==(const Profile& profile) const
 {
-  std::map<std::string, std::string>::const_iterator it = profile.begin();
-  for(; it != profile.end(); it++)
-    {
-      Chronos::ProfileMsg::ProfileEntry* profileEntry = profileMsg.add_entry();
-      profileEntry->set_oid(it->first);
-      profileEntry->set_data(it->second);
-    }
+  if (m_entries.size() != profile.m_entries.size())
+    return false;
+
+  for(map<string, string>::const_iterator it = m_entries.begin(); it != m_entries.end(); it++) {
+    map<string, string>::const_iterator found = profile.m_entries.find(it->first);
+    if (found == profile.m_entries.end())
+      return false;
+    if (found->second != it->second)
+      return false;
+  }
+
+  return true;
+}
+
+bool
+Profile::operator!=(const Profile& profile) const
+{
+  return !(*this == profile);
+}
+
+Chronos::ProfileMsg&
+operator<<(Chronos::ProfileMsg& profileMsg, const Profile& profile)
+{
+;
+  for (map<string, string>::const_iterator it = profile.begin(); it != profile.end(); it++) {
+    Chronos::ProfileMsg::ProfileEntry* profileEntry = profileMsg.add_entry();
+    profileEntry->set_oid(it->first);
+    profileEntry->set_data(it->second);
+  }
   return profileMsg;
 }
 
 Chronos::ProfileMsg&
-operator >> (Chronos::ProfileMsg& profileMsg, Profile& profile)
+operator>>(Chronos::ProfileMsg& profileMsg, Profile& profile)
 {
-  for(int i = 0; i < profileMsg.entry_size(); i++)
-    {
-      const Chronos::ProfileMsg::ProfileEntry& profileEntry = profileMsg.entry(i);
-      profile[profileEntry.oid()] = profileEntry.data();
-    }
+  for (int i = 0; i < profileMsg.entry_size(); i++) {
+    const Chronos::ProfileMsg::ProfileEntry& profileEntry = profileMsg.entry(i);
+    profile[profileEntry.oid()] = profileEntry.data();
+  }
 
   return profileMsg;
 }
 
-}//chronos
+} // namespace chronos
