refactoring in graph package