optimized code for experiment