refator the graph creator