added forEachIn and forEachOf functions