optimized script.