Add index method and refactor