refactoring diagram IO done