Fix determinant zero bug