Corrected Template Logic