refactored dgraph implementation