Save memory by using generators