Calculating the determinant