reimplement Bill's cofactor using getCofactor