graphs refactoring