diff --git a/domain_bonus_login_restrict/domain_bonus_login_restrict.module b/domain_bonus_login_restrict/domain_bonus_login_restrict.module
index af3e84e..8ce3fe0 100755
--- a/domain_bonus_login_restrict/domain_bonus_login_restrict.module
+++ b/domain_bonus_login_restrict/domain_bonus_login_restrict.module
@@ -52,29 +52,45 @@ function domain_bonus_login_restrict_form_alter(&$form, $form_state, $form_id) {
  */
 function domain_bonus_login_restrict_user($op, &$edit, &$account, $category = NULL) {
 
-  if ($op == 'login') {
+  switch($op) {
+    case 'login':
 
-    // if set make user check by domain affiliation 
-    if (variable_get('domain_bonus_login_restrict', 0) && !user_access('login to any domain')) {
-      global $user;
-      global $_domain;
+      // if set make user check by domain affiliation 
+      if (variable_get('domain_bonus_login_restrict', 0) && !user_access('login to any domain')) {
+        global $user;
+        global $_domain;
       
-      $user_domains = domain_get_user_domains($user);
+        $result = db_query("SELECT domain_id FROM {domain_editor} WHERE uid = %d", $user->uid);
 
-      // user_domains retruns [-1] = -1 for current domain
-      // make it in proper way 
-      if ($user_domains[-1] == -1) {
-        $user_domains[0] = TRUE;
-      }
+        while ($data = db_fetch_object($result)) {
+          if ($data->domain_id == 0) {
+            $user_domains['-1'] = -1;
+          }
+          else {
+            $user_domains[$data->domain_id] = $data->domain_id;
+          }
+        }
+
+        // user_domains retruns [-1] = -1 for current domain
+        // make it in proper way 
+        if ($user_domains[-1] == -1) {
+          $user_domains[0] = TRUE;
+        }
 
-      // if user doesn't belong to this domain
-      if (!$user_domains[$_domain['domain_id']]) {
-        // logout this user
-        session_destroy();
-        module_invoke_all('user', 'logout', NULL, $user);
-        // Load the anonymous user
-        $user = drupal_anonymous_user();
+        // if user doesn't belong to this domain
+        if (!$user_domains[$_domain['domain_id']]) {
+          // logout this user
+          session_destroy();
+          module_invoke_all('user', 'logout', NULL, $user);
+          // Load the anonymous user
+          $user = drupal_anonymous_user();
+          
+          // get the domain url
+          $url = db_result(db_query("SELECT subdomain FROM {domain} WHERE domain_id = %d", array_shift($user_domains)));
+          $url = 'http://'.$url.'/user/login';
+          drupal_set_message(t("You tried to login to a domain you don't have access to. <a href='@url'>Click here to go to the correct domain's login page.</a>", array('@url' => $url)), "error");       
+        }
       }
-    }
+    break;
   }
 }
