diagram refactoring