Refactor index to use built-in methods.