better function name, added comment, removed empty foreach