Improve loop markup hierarchy