DRYed up the jacobi implementation.