add diag and initialize count