fix generate_bell with recursive algorithm

TODO: replace with a non-recursive algorithm.