reshuffle templating logic