556 Rotate graph, refactoring