diff --git a/FunctionSpace/BasisTest.cpp b/FunctionSpace/BasisTest.cpp
index 441f800ed56b83b7779595cc0ae334aa15c09302..f215d28a645d2386a22c9025edf6902c8083e36b 100644
--- a/FunctionSpace/BasisTest.cpp
+++ b/FunctionSpace/BasisTest.cpp
@@ -19,7 +19,7 @@
 
 using namespace std;
 
-int ain(int argc, char** argv){
+int basisTest(int argc, char** argv){
   // Init Gmsh //
   GmshInitialize(argc, argv);
 
diff --git a/FunctionSpace/FunctionSpace.cpp b/FunctionSpace/FunctionSpace.cpp
index 770a5813eace6de3ca026c85e7e038dd8ea18bc0..22024d648af570f1fbf6349267248a31d2bb4a10 100644
--- a/FunctionSpace/FunctionSpace.cpp
+++ b/FunctionSpace/FunctionSpace.cpp
@@ -92,17 +92,17 @@ vector<Dof> FunctionSpace::getKeys(const MElement& elem) const{
   int it = 0;
 
   // Add Vertex Based Dof //
-  for(int i = 0; i < nVertex; i++){
-    for(int j = 0; j < nFVertex; j++){
-      myDof[it].setDof(mesh->getGlobalId(*vertex[i]), j);
+  for(int i = 0; i < nFVertex; i++){
+    for(int j = 0; j < nVertex; j++){
+      myDof[it].setDof(mesh->getGlobalId(*vertex[j]), i);
       it++;
     }
   }
   
   // Add Edge Based Dof //
-  for(int i = 0; i < nEdge; i++){
-    for(int j = 0; j < nFEdge; j++){
-      myDof[it].setDof(mesh->getGlobalId(edge[i]), j);
+  for(int i = 0; i < nFEdge; i++){
+    for(int j = 0; j < nEdge; j++){
+      myDof[it].setDof(mesh->getGlobalId(edge[j]), i);
       it++;
     }
   }
@@ -116,8 +116,8 @@ vector<Dof> FunctionSpace::getKeys(const MElement& elem) const{
   }
   */
   // Add Cell Based Dof //
-  for(int j = 0; j < nFCell; j++){
-    myDof[it].setDof(mesh->getGlobalId(element), j);
+  for(int i = 0; i < nFCell; i++){
+    myDof[it].setDof(mesh->getGlobalId(element), i);
     it++;
   }