Optimize loop to setup step data structure.