refactor diagram