diff --git a/templates/index.html.ep b/templates/index.html.ep
index 01e03b3..ae06752 100644
--- a/templates/index.html.ep
+++ b/templates/index.html.ep
@@ -1,33 +1,4 @@
% layout 'default',
% title => $c->board_name;
-<% my $cat_header = begin %>
- % my $_cat_id = shift; my $_name = shift;
-
-<% end %>
-
-<% my $subf_item = begin %>
- % my $_subf_id = shift; my $_cat_id = shift;
- % my $_name = shift;
-
-<% end %>
-
-<%
-foreach my $category ($category_tree->getAllChildren) { %>
- <%= $cat_header->(
- $category->getNodeValue,
- $c->schema->resultset('Categories')->
- title_from_id($category->getNodeValue)) %>
-<%
- foreach my $subforum ($category->getAllChildren) { %>
- <%= $subf_item->(
- $subforum->getNodeValue,
- $category->getNodeValue,
- $c->schema->resultset('Subforums')->
- title_from_id($subforum->getNodeValue)) %>
-<% }} %>
\ No newline at end of file
+%= include 'items/_list_subf_cat'
\ No newline at end of file
diff --git a/templates/items/_list_subf_cat.html.ep b/templates/items/_list_subf_cat.html.ep
new file mode 100644
index 0000000..a4d9e30
--- /dev/null
+++ b/templates/items/_list_subf_cat.html.ep
@@ -0,0 +1,32 @@
+% # this requires that you pass a category tree object to
+% # any template that includes this component
+<% my $cat_header = begin %>
+ % my $_cat_id = shift; my $_name = shift;
+
+<% end %>
+
+<% my $subf_item = begin %>
+ % my $_subf_id = shift; my $_cat_id = shift;
+ % my $_name = shift;
+
+<% end %>
+
+<%
+foreach my $category ($category_tree->getAllChildren) { %>
+ <%= $cat_header->(
+ $category->getNodeValue,
+ $c->schema->resultset('Categories')->
+ title_from_id($category->getNodeValue)) %>
+<%
+ foreach my $subforum ($category->getAllChildren) { %>
+ <%= $subf_item->(
+ $subforum->getNodeValue,
+ $category->getNodeValue,
+ $c->schema->resultset('Subforums')->
+ title_from_id($subforum->getNodeValue)) %>
+<% }} %>
\ No newline at end of file