refactor graphing tool