added is_square_matrix() utility function