Moved the graph creation outside of the anon funtion to be global