fixed foreach loop to combine properly