make more efficient loop