add with index added refactor