added custom graph implementation + refactoring