changed sample_indices from double pointer to vector, valgrind complains memory leak, and heisenbug results in seg fault sometimes