Refactor index create