determinant refactoring