diff --git a/inc/auth.php b/inc/auth.php
index 10f33bcf31488b04fc323113e78c09e3e9fc62ab..85576b680a570fb1aff6d3950dfc972d56f50736 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -344,24 +344,22 @@ function auth_aclcheck($id,$user,$groups){
   global $conf;
   global $AUTH_ACL;
 
-  # if no ACL is used always return upload rights
+  // if no ACL is used always return upload rights
   if(!$conf['useacl']) return AUTH_UPLOAD;
 
-  $user = auth_nameencode($user);
+  //make sure groups is an array
+  if(!is_array($groups)) $groups = array();
 
-  //if user is superuser return 255 (acl_admin)
+  //if user is superuser or in superusergroup return 255 (acl_admin)
   if(auth_isadmin($user,$groups)) { return AUTH_ADMIN; }
 
-  //make sure groups is an array
-  if(!is_array($groups)) $groups = array();
+  $user = auth_nameencode($user);
 
   //prepend groups with @ and nameencode
   $cnt = count($groups);
   for($i=0; $i<$cnt; $i++){
     $groups[$i] = '@'.auth_nameencode($groups[$i]);
   }
-  //if user is in superuser group return 255 (acl_admin)
-  if(auth_isadmin($user,$groups)) { return AUTH_ADMIN; }
 
   $ns    = getNS($id);
   $perm  = -1;