template rearranging