Using switch-like structure in generate()