modified to graph by index