foreach theory