modified add_to-index