reduction generation moved into template