Refactor on subgraphs