added generate function