refactore graph