fix error 'next is undefined'