beginning refactor of the graph building code