graph factory refactor