templateOrdering function added