Implement generate()