create generate function