diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote
index fd763b8f..56c1cbc1 100755
--- a/cdist/conf/type/__acl/gencode-remote
+++ b/cdist/conf/type/__acl/gencode-remote
@@ -41,10 +41,12 @@ do
         then
             if [ "$is_dir" = '1' ]
             then
-                acl="$( echo "$acl" | sed 's/X$/x/' )"
+                rep=x
             else
-                acl="$( echo "$acl" | sed 's/X$/-/' )"
+                rep=-
             fi
+
+            acl="$( echo "$acl" | sed -r "s/(.*)X/\1$rep/" )"
         fi
 
         if echo "$parameter" | grep -Eq '(mask|other)'