refactoring of get_diagnostics