refactor genJac algo