refactor graph creator