Refactor
Refactored to get the index