finixhed the graph generation code