you could simplify this code using the ``{% for %}{% else %}{% endfor %}`` structure