I don't see any foreach or for, I think you can delete this comment. The function above seems fine, as it's not modifying vars outside the scope of the loop.