refactoring for diagnostic commands