added sum and diag