Adding complete code for Diagnostic Service