added security checks for determinant function