foreach2 modified