refactor graph