changed i to phase_index in plot_excess()