diff --git a/server/sql_app/api/auth.py b/server/sql_app/api/auth.py
index 425d8baee3ef26897943994dedcd6ce8f69ceba1..740ac40b3ca71c0c9f0e85ad8fc54636b6b246f8 100644
--- a/server/sql_app/api/auth.py
+++ b/server/sql_app/api/auth.py
@@ -149,10 +149,9 @@ async def login(username: str = Form(...), password: str = Form(...), db: Sessio
             refresh_token = Authorize.create_refresh_token(subject="guest", expires_time=False)
     else:
         usr = fake_users_db.get(username)
-        if usr != None:
-            if usr["username"] == username and usr["password"] == password:
-                access_token = Authorize.create_access_token(subject="admin", expires_time=False)
-                refresh_token = Authorize.create_refresh_token(subject="admin", expires_time=False)
+        if usr is not None and (usr["username"] == username and usr["password"] == password):
+            access_token = Authorize.create_access_token(subject="admin", expires_time=False)
+            refresh_token = Authorize.create_refresh_token(subject="admin", expires_time=False)
         else:
             return """
                 <html>
diff --git a/server/sql_app/api/teams_web.py b/server/sql_app/api/teams_web.py
index 15c44b79363cb61dbe287d8ed08082c134755786..535ef16a0a03baaaced724bbe66531fb64c21eff 100644
--- a/server/sql_app/api/teams_web.py
+++ b/server/sql_app/api/teams_web.py
@@ -99,5 +99,10 @@ async def team_change_process(team_id: int, db:Session = Depends(get_db), name:
     current_user = Authorize.get_jwt_subject()
     if current_user != "admin":
         return RedirectResponse(url=f"/logs-web", status_code=303)
-    team = crud.change_team(db, team_id, name)
+    teams = crud.get_teams(db, 0, 100)
+    teams_names = []
+    for t in teams:
+        teams_names.append(t.name)
+    if name not in teams_names:
+        team = crud.change_team(db, team_id, name)
     return RedirectResponse(url=f"/teams-web", status_code=303)
\ No newline at end of file
diff --git a/server/sql_app/crud.py b/server/sql_app/crud.py
index 2935853b8f475bb06e34d8835788ecbcf056ce0b..d0158cc651f0c5df6a3bf7418b4e24bd3f9652b9 100644
--- a/server/sql_app/crud.py
+++ b/server/sql_app/crud.py
@@ -965,7 +965,7 @@ def get_filtered_devices(db: Session, keyman_id: str, license_name: str, license
             for l in dev_lics:
                 lic_ids += str(l.device_id) + ", "
             def_lic_ids = lic_ids[:-2] + ")"
-            if len(def_lic_ids) < 1:
+            if len(def_lic_ids) <= 1:
                 def_lic_ids = "(-1)"
             if before_me:
                 execute_string += " AND device.id IN " + def_lic_ids
@@ -987,7 +987,7 @@ def get_filtered_devices(db: Session, keyman_id: str, license_name: str, license
             for lic in licen_devs:
                 ids += str(lic.device_id) + ", "
             def_ids = ids[:-2] + ")"
-            if len(def_ids) < 1:
+            if len(def_ids) <= 1:
                 def_ids = "(-1)"
             if before_me:
                 execute_string += " AND device.id IN " + def_ids