integrated the graph part almost