added diag func