Wrote a graph function