graph refactor