fixing apply template