Add back accidentally deleted loop code