add generator function, work fine