adding diag func