Fix foreachE

@garyb Would you mind reviewing?