Replace map with generator