Fix determinant function