add conditional test for square matrix check and determinant check