Moved indexing to template definition