diff --git a/lib/PinModuleHelperFunctions.php b/lib/PinModuleHelperFunctions.php
new file mode 100644
index 0000000..fe04996
--- /dev/null
+++ b/lib/PinModuleHelperFunctions.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Drupal\pin;
+
+/**
+ * PinModuleHelperFunctions short summary.
+ *
+ * PinModuleHelperFunctions description.
+ *
+ * @version 1.0
+ * @author David
+ */
+class PinModuleHelperFunctions
+{
+  static function SendMessage() {
+    if (!variable_get('pin_username')) return;
+    $conn = new XMPPHP_XMPP(variable_get('pin_server'),
+                variable_get('pin_port'),
+                variable_get('pin_username'),
+                variable_get('pin_password'),
+                'xmpphp',
+                variable_get('pin_domain'),
+                $printlog=false,
+                $loglevel=XMPPHP_Log::LEVEL_INFO);
+
+    try {
+      $conn->connect();
+      $conn->processUntil('session_start');
+      $conn->presence();
+      $conn->message(variable_get('pin_username') . "@" . variable_get('pin_domain'), $msg);
+      $conn->disconnect();
+      return 1;
+    }
+    catch(XMPPHP_Exception $e) {
+      die($e->getMessage());
+    }
+  }
+}
diff --git a/pin.info b/pin.info
index 7771fe9..29f9243 100644
--- a/pin.info
+++ b/pin.info
@@ -1,7 +1,7 @@
-; $Id$
 name = Pin Module
 description = Provide pin for admin login.
 core = 7.x
 package = "Pin"
 version = "7.x-0.1-dev"
 dependencies[] = libraries
+dependencies[] = xautoload (>= 7.x-4.0)
\ No newline at end of file
diff --git a/pin.module b/pin.module
index 74bb178..40e6dab 100644
--- a/pin.module
+++ b/pin.module
@@ -1,5 +1,8 @@
 <?php
 
+// ENABLE PSR-4 NAMESPACES
+xautoload()->registerModulePsr4(__FILE__, 'lib');
+
 function pin_init() {
 	if ($path = libraries_get_path("XMPPHP")) {
 	  require $path . '/XMPP.php';
@@ -118,7 +121,7 @@ function pin_config_form_submit($form, &$form_state) {
 	if ($form['pin_port']['#value'])     variable_set('pin_port',     $form['pin_port']['#value']);
 	variable_set('pin_status',   $form['pin_status']['#value']);
 	if (!$form_state['input']['pin_status'] && $form['pin_username']['#value'] &&  $form['pin_password']['#value']) {
-		$_ = _send_msg('This is a test message from ' .$_SERVER['HTTP_HOST'].'!  You can activate de Pin module now.');
+		$_ = Drupal\pin\PinModuleHelperFunctions::SendMessage('This is a test message from ' .$_SERVER['HTTP_HOST'].'!  You can activate de Pin module now.');
 		if ($_ == 1) print t("If you receive soon a jabber message your config is working and you can activate the module");
 	}
 
@@ -188,7 +191,7 @@ function pin_user_login(&$edit, $account){
 			$pin_code = mt_rand(0,9) . rand(0,9) . mt_rand(0,9) . rand(0,9) . mt_rand(0,9);
 			variable_set('pin_username_login' , $account->name);
 			variable_set('pin_code', $pin_code);
-			$_ = _send_msg("Your pin code is " . $pin_code);
+			$_ = Drupal\pin\PinModuleHelperFunctions::SendMessage("Your pin code is " . $pin_code);
 			if ($_ != 1) die(t('error sending the PIN via jabber :('));
 
 			session_destroy();
@@ -197,27 +200,4 @@ function pin_user_login(&$edit, $account){
 
 		}
 	}
-}
-
-function _send_msg($msg) {
-	if (!variable_get('pin_username')) return;
-	$conn = new XMPPHP_XMPP(variable_get('pin_server'),
-							variable_get('pin_port'),
-							variable_get('pin_username'),
-							variable_get('pin_password'),
-							'xmpphp',
-							variable_get('pin_domain'),
-							$printlog=false,
-							$loglevel=XMPPHP_Log::LEVEL_INFO);
-
-	try {
-		$conn->connect();
-		$conn->processUntil('session_start');
-		$conn->presence();
-		$conn->message(variable_get('pin_username') . "@" . variable_get('pin_domain'), $msg);
-		$conn->disconnect();
-		return 1;
-	} catch(XMPPHP_Exception $e) {
-		die($e->getMessage());
-	}
-}
+}
\ No newline at end of file
