Refactored graphEngine