added checks for sparse matrices