refactor graph module