replace index with template