-% for a in sorted(attributes.keys(), key=lambda attr: attributes[attr]['weight']):
+<%def name="form_col(l)">
+% for a in l:
<% attr = attributes[a] %>
-% if counter == len_second_column:
+% endfor
+%def>
+
+
+${form_col(lc1)}
-% endif
-% endfor
+${form_col(lc2)}
diff --git a/resources/templates/selfmodify.tmpl b/resources/templates/selfmodify.tmpl
index bd1ac0c..28e4ac2 100644
--- a/resources/templates/selfmodify.tmpl
+++ b/resources/templates/selfmodify.tmpl
@@ -3,9 +3,10 @@