title: TypeError: Cannot call method 'toLowerCase' of undefined
body: <p>I ran into an error and I don't know why. I try to transform all the character into lowercase before inserting into database and for comparison purposes.
  At the first function <code>this.addUser</code> I call toLower to transform it become lowercase it has no problem but at second function <code>this.checkPublicUsername</code> I call toLower it display an error in my terminal said that  <code>TypeError: Cannot call method 'toLowerCase' of undefined</code></p>
  
  <pre><code>function toLower (text) {
      return text.toLowerCase();
  }
  
  this.addUser = function(data,callback) {
      "use strict";
      // Generate password hash
      var salt = bcrypt.genSaltSync();
      var password_hash = bcrypt.hashSync(data.password, salt);
      // transform all character into lowercase
      var real = toLower(data.publicUsername);
      // Create user document
      var user = {
          '_id': data.email,
          'email':data.email,
          'password': password_hash,
          'name':{
              'firstName': data.firstName,
              'lastName': data.lastName
          },
          'penName': data.penName,
          'publicUsername':{
              'display':data.publicUsername,
              'real':real
          }
      };
      users.insert(user, function (err, result) {
          "use strict";
  
          if (!err) {
              console.log("Inserted new user");
              return callback(null, result[0]);
          }
          if (err) console.log(err)
  
          return callback(err, null);
      });
  }
  
  this.checkPublicUsername = function(data,callback) {
      "use strict";
      var real = toLower(data);
      var publicUsername = {
          "publicUsername.real":real
      }
      users.find(publicUsername).count(function(err, result) {
          callback(null,result);
      })
  
  }
  </code></pre>
  
  <h3> call checkPublicUsername </h3>
  
  <pre><code> users.checkPublicUsername(data.publicUsername, function(err, result){
       if(result){
       callback(new Error('"'+data.publicUsername+'" has been taken. Please choose another.'), null);
               }
          });
  </code></pre>