More loop optimization