optimization for large bases