Refactor into an index