refactor indexing of fields