generator rewritten (no memory allocation test anymore)