using pointers instead of references so that we can build the index map later, with the train method