Added check for upper triangular