Remove foreach dependency