more efficient loop