Optimize one loop