Diag routine coded