put residue and jacobian in the same function; new b.c. method