Refactor to simplify graph transition