refactor of graph