Implement generate_code for fetch sequence