added intermediate code to generate the graph