remove foreach from functions