Change apply to generate