fixed closing foreach block