finalized template functionality