eliminated the todos; modified properties with lambda;
factored substitute_indices