finished determinant code