Moved the graph code into observer