Optimization for generating more than 1M nodes