organize template hierarchy