replace deprecated function nnz with countnz