Refactor index