Remove unnecessary foreach