diff --git a/pwm b/pwm
index a9f4556ab5d3d1a87d082d1dca32a3d6fb406020..2d30be1df337bfeff167c000589cfb10f9b2ec66 100755
--- a/pwm
+++ b/pwm
@@ -62,8 +62,12 @@ def emails_to_ids(emails: List[str], headers: Dict[str, str]) -> List[int]:
 
     for email in emails:
         # Dirty and hackish way that attempts to extract the username from the email.
-        # It's inefficient, but currently there is now way to reliably obtain
+        # It's inefficient, but currently there is no way to reliably obtain
         # the username from the email.
+        # new strategy: - stop when we reach the "." or when we get more than 1 result
+        # Example of tricky users:
+        # pierre-louis.roden@etu.hesge.ch -> login AAI: pierrelo.roden
+        # joel.ferreirapinto@etu.hesge.ch -> login AAI: joelfili.ferreira
         username = email.split("@")[0]
         #print("Email: ",email)
 
@@ -71,11 +75,17 @@ def emails_to_ids(emails: List[str], headers: Dict[str, str]) -> List[int]:
             #print("Guessed username: ",username)
             user_requested = requests.get(BASE_API_URL + '/users', params={'search': username}, headers=headers).json()
 
-            if len(user_requested) == 0:
+            nb_users = len(user_requested)
+            if nb_users == 0:
                 #print('No user %s found, another try...' % email)
                 lastchar = username[-1]
                 username = username.rstrip(lastchar)
+                if username[-1] == '.':  # stop if we reach the . -> probably at least one wrong person match the first name
+                    break
                 continue
+            elif nb_users > 1:
+                print('Too many users found for email %s, aborting.' % email)
+                exit(1)
 
             #print(json.dumps(user_requested, indent=4))
             user_ids.append(user_requested[0]['id'])
@@ -104,7 +114,7 @@ def create_repository(token: str, group_id: str, emails: List[str], name: str, i
           project['web_url'] + "' created")
 
     # Allow users with developer access level to push and merge on master
-    access_level = 30
+    access_level = 40
     params = {'name': 'master', 'push_access_level': str(
         access_level), 'merge_access_level': str(access_level)}
     requests.post(BASE_API_URL + '/projects/' +
@@ -113,7 +123,7 @@ def create_repository(token: str, group_id: str, emails: List[str], name: str, i
     # Get students ids from their emails
     user_ids = emails_to_ids(emails, headers)
 
-    # Add each student as project's developer (level 30)
+    # Add each student as maintainer (level 40)
     for user_id in user_ids:
         params = {'user_id': user_id, 'access_level': access_level}
         if expires_at: