diff --git a/space_view3d_materials_utils.py b/space_view3d_materials_utils.py
index 75e53a52baa2a60c7c3c887b159fbfb806743432..0b984ba8b7e215a43c97654fe445e3b355d7e00f 100644
--- a/space_view3d_materials_utils.py
+++ b/space_view3d_materials_utils.py
@@ -391,16 +391,16 @@ def assign_mat(matname="Default"):
                 ob.data.materials.append(target)    
                 
             #now assign the material:
-                me =ob.data
-                if allfaces:
-                    for f in me.faces:
+            me =ob.data
+            if allfaces:
+                for f in me.faces:
+                    f.material_index = index
+            elif allfaces == False:
+                for f in me.faces:
+                    if f.select:
                         f.material_index = index
-                elif allfaces == False:
-                    for f in me.faces:
-                        if f.select:
-                            f.material_index = index
-                me.update()
-            
+            me.update()
+        
 
 
     #restore the active object
@@ -710,3 +710,4 @@ def unregister():
 
 if __name__ == "__main__":
     register()
+    
\ No newline at end of file